Problem description
I am using a bar chart to describe the number of problems. There should be no decimal place in the circumstances. How to avoid the phenomenon of axis text appearing 0.5?
Solution
- You can use
the axes.tick.noDecimals
property to configure continuous axes without decimals
axes: [
{
orient: 'left',
tick:{
noDecimals: true
}
}
],
Code example
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;
Results show
Related Documents
- github:https://github.com/VisActor/VChart
-
noDecimals
configuration: https://visactor.io/vchart/option/barChart-axes-linear#tick.noDecimals
Top comments (0)