问题描述
我想根据我得到的数据显示图表上的所有点,但我不想显示它们的所有标签,因为这样图表的可读性不是很好.我在文档中寻找它,但找不到任何限制它的参数.
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?
我现在有这样的事情:
如果我能留下每四分之三的标签,那就太好了.但我对标签选项一无所知.
If I could just leave every third-fourth label, it would be great. But I found absolutely nothing about labels options.
推荐答案
尝试添加 options.scales.xAxes.ticks.maxTicksLimit
选项:
Try adding the options.scales.xAxes.ticks.maxTicksLimit
option:
xAxes: [{
type: 'time',
ticks: {
autoSkip: true,
maxTicksLimit: 20
}
}]
这篇关于限制 Chart.js 折线图上的标签数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!