Chartjs-How remove duplicates xAxis labels and show all values on chart

1👍

Actually, data values have not really been deleted but you can only see the first n values. Their number corresponds to the number of left over labels. Also the values do now no longer match the correct labels. Remember that the number of labels must be the same as the number of data values.

Technically, when removing duplicate labels, you’ll end up having multiple y values at the same x coordinate. If this is what you want, you better convert the line chart into a scatter chart (see this answer).

An other option would be to sum up values at the same x coordinate, same as explained in this answer.

Again another option would be to define a ticks.callback function on the x-axis that would make sure to return identical labels only once and null otherwise (see this answer given to a similar question).

Leave a comment