我使用chart.js 2.8
和chartjs-plugin-annotation.js
我有一个条形图。
我的标签是:[1.0 - 2.8], [2.8 - 4.6], [6.4 - 8.2], [8.2 - 10.0]
var ctx = document.getElementById("myChart").getContext("2d");
new Chart(ctx, {
type: "bar",
data: {
labels: labels,
datasets: [{
data: datas
}]
},
options: {
annotation: {
annotations: [{
type: "line",
mode: "vertical",
scaleID: "x-axis-0",
value: "2.8 - 4.6", //value must be equal a label :(
borderColor: "red",
label: {
content: "TODAY",
enabled: true,
position: "top"
}
}]
}
}
});
我希望垂直线精确地在 2.4 点上绘制。但是垂直线只能在标签值处绘制。我该如何解决?