Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line chart with large number of labels on X axis

Tags:

chart.js

I'm using Chart.js to implement a Line chart. The X axis of this chart has many points, for example the integer range 1 to 200. Having this many points on the X axis causes an issue when displaying:

enter image description here

Is is possible to 'conflate' the labels so that I perhaps just show 1, 10, 20? This should only impact the labels and not remove points from the plotted line itself.

like image 472
imrichardcole Avatar asked Oct 08 '14 09:10

imrichardcole


1 Answers

What I did was when generating the array for the labels, check if i % 10 === 0 where i is the index of the label, if true, add the label to the array, if false, add empty string to the array.

Maybe not the cleanest way, but it works.

like image 73
Mark Buikema Avatar answered Oct 31 '22 14:10

Mark Buikema