我想用chatjs创建line类型的图表。问题是,我的日期格式是:{ x: real number from 0 to 1, y: integers from 0 to infinite },我希望图表在x轴上有固定的标签,比如:[0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]。
下面是我想要设置图表配置的方式:
type: 'line',
data: {
labels: ['0', '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1'],
datasets: [{
label: 'data',
data: [
{ x: 0.3, y: 446 },
{ x: 0.3331, y: 6863 },
{ x: 0.874, y: 12 },
{ x: 0.2244, y: 1565 },
{ x: 0.38899, y: 32221 },
{ x: 0.23685545, y: 3112324 },
{ x: 0.11332, y: 444423 },
{ x: 0.97694, y: 21212334 },
],
}]
},但是这显然不起作用,我该怎么做呢?
发布于 2020-10-29 03:00:07
所以我发现还有另一种图表类型的scatter。这通常只用于轴图表上的点,但它可以配置为在点之间有线。此外,如果没有必要在图上标记点,有一个配置选项可以将这些点的半径设置为0,这会使这些点隐藏起来。
https://www.chartjs.org/docs/latest/charts/scatter.html#scatter-chart
https://stackoverflow.com/questions/64578127
复制相似问题