RedCoub
RedCoub

Reputation: 23

How remove duplicates xAxis labels and show all values on chart

How i can remove all label duplicates

example img

if i remove duplicates by spread operator

labelsNonUnique = [29.03,30.03,30.03,30.03,30.03,30.03,30.03,31.03,31.03,31.03,01.04,01.04,01.04,01.04,01.04,01.04,02.04];
labels = [...new Set(labelsNonUnique)];

all duplicates been removed, but value points on chart been deleted too

example img

How to remove duplicate labels without deleting points

Upvotes: 0

Views: 2938

Answers (1)

uminder
uminder

Reputation: 26150

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).

Upvotes: 1

Related Questions