标签太稠密时如何固定X轴上的网格线数量

时间:2020-04-30 15:11:18

标签: chart.js

由于标签太紧凑,如何固定X轴上的网格线数量。 示例:https://www.chartjs.org/samples/latest/charts/line/basic.html

如果我们添加60个以上的数据标签,则将其压缩得太紧,然后再调整一些值后,轴线会调整以隐藏其间的一些值,以正确显示标签。

Condensed labels

Adjusted Labels

有没有一种方法可以控制触发点来调整轴线编号?

1 个答案:

答案 0 :(得分:0)

假设您定义了time.stepSize,则可以如下定义xAxes: [{ type: 'time', time: { unit: 'month', stepSize: 2 },

#Check the current sdk
xcrun --show-sdk-path

#Change sdk
sudo xcode-select -s /Library/Developer/CommandLineTools          #Using CommandLineTools SDK
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer   #Using XCode.app SDK

time.stepSize:网格线之间的单位数。

Chart.js内部使用Moment.js来实现time axis的功能。因此,您应该使用在单个文件中包含Moment.js的Chart.js的bundled version