【发布时间】:2019-05-04 05:04:32
【问题描述】:
使用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
这样,在坐标中不显示点的地方生成如下图:
提前致谢。
【问题讨论】:
-
当你想要一个折线图时,为什么第三行有“type: 'bar'”?
-
@DAXaholic 这是一个错字,我已经更正了。
标签: chart.js