Chartjs-Chart.js number of labels equal to number of datapoints

1👍

Interesting question. Moreover interesting library ‘Chart.js’. Even i am also working on same from past 2 months.

Solution

For this you need to create a predefined array which will be global.

var labelnames = ["1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", .....];

When ever you want your chart specific dataarrayset then do following

var count = dataArray.length; 
var requiredLabels = labelnames .slice(0,count);

Hope this will solve your problem!!

Leave a comment