如何删除重复的xAxis标签并在图表上显示所有值 [英] How remove duplicates xAxis labels and show all values on chart
问题描述
我如何删除所有重复的标签
如果我通过点差运算符删除重复项
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]标签= [...新Set(labelsNonUnique)];
所有重复项均已删除,但图表上的价值点也已删除
如何在不删除标记的情况下删除重复的标签
实际上, data
值尚未真正删除,但您只能看到前n个值.它们的数量对应于剩余的 labels
的数量.而且,这些值现在不再与正确的 labels
匹配.请记住,标签
的数量必须与 data
值的数量相同.
从技术上讲,当删除重复的标签时,您最终将在同一x坐标上具有多个y值.如果这是您想要的,最好将 line
图表转换为 scatter
图表(请参阅此答案中的解释相同./p>
同样,另一个选择是在x轴上定义 ticks.callback
函数,该函数将确保只返回相同的 labels
一次,而 null
否则(请参见类似问题的答案).
How i can remove all label duplicates
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
How to remove duplicate labels without deleting points
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).
这篇关于如何删除重复的xAxis标签并在图表上显示所有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!