This content originally appeared on DEV Community and was authored by FlyingAndFly
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.noDecimalsproperty 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
-   noDecimalsconfiguration: https://visactor.io/vchart/option/barChart-axes-linear#tick.noDecimals
This content originally appeared on DEV Community and was authored by FlyingAndFly
 
	
			FlyingAndFly | Sciencx (2024-06-17T10:59:30+00:00) Can the VChart axis be set to avoid decimals?. Retrieved from https://www.scien.cx/2024/06/17/can-the-vchart-axis-be-set-to-avoid-decimals/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.
