限制Chartjs折线图上的标签数量 [英] Limit labels number on Chartjs line chart
问题描述
我想从我获得的数据显示我的图表上的所有点,但我不想显示所有的标签为他们,因为然后图表不是很可读。
I want to display all of the points on my chart from the data I get, but I don't want to display all the labels for them, because then the chart is not very readable. I was looking for it in the docs, but couldn't find any parameter that would limit this.
我不想只使用三个标签,例如,因为那么图表也只限于三点。可能吗?
I don't want to take only three labels for example, because then the chart is also limited to three points. Is it possible?
我现在有类似的东西:
如果我可以离开每三分之一的标签,是伟大的。
and If I could just leave every third-fourth label it would be great. But I found absolutely nothing about labels options.
推荐答案
为了具体性,我们假设你的原始标签列表如下:
For concreteness, let's say your original list of labels looks like:
[0,1,2,3,4,5,6 ,8]
如果您只想显示每4个标签,请过滤标签列表, ,并且所有其他都是空字符串(例如 [0,,,,4,,,,8]
)。
If you only want to display every 4th label, filter your list of labels so that every 4th label is filled in, and all others are the empty string (e.g. ["0", "", "", "", "4", "", "", "", "8"]
).
这篇关于限制Chartjs折线图上的标签数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!