【发布时间】:2020-05-24 10:03:21
【问题描述】:
我正在寻找一种在 chart.js 图表上手动指定 x/y 刻度位置的方法,相当于 matplotlib 的 matplotlib.pyplot.xticks。该文档解释了如何create custom tick formats,但这适用于自动计算的刻度位置。如何指定刻度位置?
这是我正在使用的配置:
var config = {
type: "line",
data: {
labels: [],
datasets: [{
data: [{x: 1, y: 2}, {x: 5, y: 3}, {x: 6, y: 4}],
fill: false,
borderColor: "#1f77b4",
}],
},
options: {
scales: {
xAxes: [{
type: 'linear',
distribution: 'series',
ticks: {
min: 0.,
max: 7.,
},
}]
},
},
}
我想指定 xticks 位置,例如[0., 3.5, 5.7, 6.1],让情节看起来更像(不考虑网格线和平滑的情节线):
【问题讨论】:
-
请发布您已经拥有的代码,可能带有预期结果的图片。
-
@uminder 我编辑了我的问题