问题描述
使用柱状图描述问题数量,不存在小数个的情况,怎么避免轴文字出现 0.5 的现象?
解决方案
- 可以通过
axes.tick.noDecimals属性来配置连续轴不出现小数
axes: [
{
orient: 'left',
tick:{
noDecimals: true
}
}
],
代码示例
const spec = {
type: 'bar',
data: [
{
id: 'barData',
values: [
{ month: 'Monday', sales: 1 },
{ month: 'Tuesday', sales: 1 },
{ month: 'Wednesday', sales: 2 },
{ month: 'Thursday', sales: 0 },
{ month: 'Friday', sales: 1 }
]
}
],
axes:[{orient:"left", tick:{noDecimals: true}}],
xField: 'month',
yField: 'sales'
};
const vchart = new VChart(spec, { dom: CONTAINER_ID });
vchart.renderSync();
// Just for the convenience of console debugging, DO NOT COPY!
window['vchart'] = vchart;
结果展示
相关文档
- github:github.com/VisActor/VC…
noDecimals配置项:visactor.io/vchart/opti…