score:58
if you don't want to show point value (e.g. 0.5) labels you could write a callback function to filter the point value labels instead of using stepsize.
like this:
ticks: {
min: 0, // it is for ignoring negative step.
beginatzero: true,
callback: function(value, index, values) {
if (math.floor(value) === value) {
return value;
}
}
}
working fiddle here: https://jsfiddle.net/ma7h611l/
update:
as noted by atta h. and lekoaf below, chart.js added the precision property to ticks. it is available since version 2.7.3. see lekoaf's answer how to use this.
score:30
ticks: {
precision: 0
}
this worked equally well as the callback function above and is much cleaner.
precision, if defined and stepsize is not specified, the step size will be rounded to this many decimal places.
https://www.chartjs.org/docs/latest/axes/cartesian/linear.html
Source: stackoverflow.com
Related Query
- Set minimum step size in chart js
- Can i set dynamic step size on stepped line chart in chart.js?
- How to set axes' step size in Chart.js 2?
- Set minimum number of steps in line chart
- Set fixed label size for grouped bar chart in angular Chartjs
- How to set minimum value to Radar Chart in chart js
- Chart.js how set equal step size depending on actual data (xaxis)?
- How do I get the current step size of a chartjs chart whose stepSize I have not defined?
- How to add custom text inside the bar and how to reduce the step size in y axis in chart js( Bar chart )
- Chart.js: How to set minimum height of chart but still maintain aspect ratio?
- Set minimum and maximum axis values on chart
- Set height of chart in Chart.js
- In Chart.js set chart title, name of x axis and y axis?
- Chart.js - How to set a line chart dataset as disabled on load
- chart js 2 how to set bar width
- How set color family to pie chart in chart.js
- Chart.js line chart set background color
- chartjs : how to set custom scale in bar chart
- Chart.js setting maximum bar size of bar chart
- Chart JS - set start of week for x axis time series
- set background color to save canvas chart
- Can I specify a different font size for each row of text in Chart Title?
- ChartJS - Line Chart with different size datasets
- Is it possible to set up 0 as a minimum number for bar chart? react-chart.js-2
- set y-axis scale manually in a bar chart using angular-chart.js
- how to set chart.js grid color for line chart
- Chart.js: Minimum value for x-axis at horizontal stacked bar chart
- How do you set pie chart colors in angular-chart.js
- How to dynamically set ChartJs line chart width based on dataset size?
- Can't size doughnut chart from chart.js
More Query from same tag
- ChartJS line chart drag and zoom
- Change point size and color on hover in chartjs
- Uncaught TypeError: t.ticks.map is not a function, Chart.JS
- How to set vertical lines for new day on x-axis in ChartJS v3.x
- Set Radar(spider) chart version 2.x (2.4.0) steps(interval) in Chart.js
- ChartJS Polar Area Chart Scale Removing
- chart annotations not showing in Angular 2
- React ChartJS Scatter Plot - cannot plot the data
- How can I modify category labels font size in Chart.JS V2?
- Overlay loading indicator before data and charts are loaded
- Add Data Labels onto a bubble chart on chart.js
- Cannot read property 'getElementAtEvent' of undefined, Typescript
- Chartjs does not show annotations when x axis is of type time
- Chart.js with Angular component - Type 'string' is not assignable to type 'ChartTitleOptions | undefined'
- How to add horizontal scroll to a bar graph in chartjs?
- How to set chartJs Doughnut labels on right side?
- Generate multiple line charts in Django with ChartJS
- Chart.js Console JS Error while destroy the Chart on click event
- Is there a max width of canvas Chart.js can draw charts within?
- Chart JS Error : Uncaught TypeError: Cannot read property 'top' of undefined
- Chart.js multiple columns of data for the same label
- How to add label in chart.js for polar chart area
- gradient background on radar chartjs
- chartjs line graph destroy function is not clearing the old chart instances
- how to customize tool tip while mouse go over bars on Chart js bar chart
- ChartJS how to sync animations when page loads
- Is it possible to have a canvas next to another canvas without space on the bottom?
- How to display grouped bar chart using chart.js?
- Dynamically update value for horizontal line in annotation plugin for Chart.js in Angular 5
- How to make dashed thick lines with dots in ChartJS ? Is it possible?