I’m working on a scatter with chartsjs.
I declare all the value, type category.
I want to hide some value from the scale.
My scale is: 0,5,10,15 etc
I don’t want to show the label for value 5 and 15.
How can I do?
Thanks
I can only hide all the value but nor certain.
2
Answers
thank you all. I'm not very familiar with js and I didn't know about the callback function. works.
thanks, solved.
I believe you want the X-axis to show the ticks with stepSize=5, but want to hide those 5, 15, 25, etc.
For chartjs, to do what you want, you can specify the ticks with callback like the following:
and then use the following callback function (I have used remainder (%) to do the calculation), for your case, the if condition statement can be
if (value %5 ==0 && value %10 !=0) {....} else {....}
:So the complete code (Scatter example) will be like:
See result here:
Note: If you want to hide 5, 15, 25 on Y-axis instead, then put the ticks block inside the
scales
>y