gpt4 book ai didi

Chart.js 类别 y 轴折线图

转载 作者:行者123 更新时间:2023-12-01 06:06:49 31 4
gpt4 key购买 nike

使用 Chart.js 2.0,如何绘制带有类别 y 轴的折线图?

这是我的代码

    var ctx = $("#myChart");
var scatterChart = new Chart(ctx, {
type: 'line',
data: {
labels: ["January", "February", "March"],
datasets: [{
label: "January",
data: [{
x: -10,
y: "January"
}, {
x: 0,
y: "February"
}, {
x: 10,
y: "February"
}]
}]
},
options: {
scales: {
xAxes: [{
type: 'linear',
position: 'bottom'
}],
yAxes: [{
type: 'category',
position: 'left'
}]
},
showLines: false
}
});

这是 JSFiddle

这样,在坐标中未显示点的情况下,会生成以下图形:

enter image description here

提前致谢。

最佳答案

我更新到最新版本的 chart.js (2.8.0) 并且您的代码有效。您可以升级您使用的 Chart.js 版本吗?

关于Chart.js 类别 y 轴折线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37649141/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com