类似 (https://www.visactor.io/vchart/demo/line-chart/basic-line)这样的数据全为0的折线图,
x轴的位置会使折线居中。想要调整X轴的位置,使X轴与Y刻度为0对齐,该如何实现?
类似 (https://www.visactor.io/vchart/demo/line-chart/basic-line)这样的数据全为0的折线图,
x轴的位置会使折线居中。想要调整X轴的位置,使X轴与Y刻度为0对齐,该如何实现?
不同图表库的解决方案不一样,根据你给的demo,只需要将Y轴的axes-linear.
`zero 设置为
true`即可。
barChart-axes-linear.
`zero` = true
仅当轴为线性轴时生效,是否包含 0 值。当配置了 min 和 max,该配置项失效。代码参考 Code Example
const spec = {
type: 'line',
data: {
values: [
{
time: '2:00',
value: 0
},
{
time: '4:00',
value: 0
},
{
time: '6:00',
value: 0
},
{
time: '8:00',
value: 0
},
{
time: '10:00',
value: 0
},
{
time: '12:00',
value: 0
},
{
time: '14:00',
value: 0
},
{
time: '16:00',
value: 0
},
{
time: '18:00',
value: 0
}
]
},
xField: 'time',
yField: 'value',
axes:[
{
orient: 'left',
zero: true,
}
]
};
在线效果参考:https://codesandbox.io/s/data-is-all-0-smhq6h
基础折线图demo:https://www.visactor.io/vchart/demo/line-chart/basic-line
坐标轴教程:https://www.visactor.io/vchart/guide/tutorial_docs/Chart_Conc...
相关api:https://www.visactor.io/vchart/option/lineChart-axes-linear#zero
2.6k 阅读
1 回答1k 阅读
1 回答1.2k 阅读
2 回答618 阅读
试一下y轴最小值给0