我需要在我的bar
图表上添加一条简单的点/垂直线,它有一个动态的X值,0代表Y值.预览我需要的内容(红点):
绿色值是动态的.
预览我的当前状态:
Where 3.30应该是点的X坐标-[3.30,0].
我用Vue chart表示图表,我试着用bar
和scatter
创建一个mixed,但scatter
需要type: 'linear'
,因为它是xAxis
,这不适合我对bar
图表的需要.
所以我try 了chartjs-plugin-annotation,它是box
类型,接受"坐标",但这里的问题是X
值must be a fixed value on the X axis(labels
对象).如果我把X轴[3,0]放进go ,它会起作用,但是如果有一个十进制数,比如[3.5,0],它就不会起作用.
// data
options: {
responsive: true,
maintainAspectRatio: false,
legend: {
display: false
},
scales: {
yAxes: [{
ticks: {
min: 0,
max: 1,
stepSize: 0.1
}
}]
}
}
// computed
labels: [1, 2, 3, 4, 5, 6], // fixed value, there are always 6 bars
datasets: [
{
label: 'Values',
backgroundColor: '#f89098',
data: this.tableInputValues // array of decimal values
}
]
So, my question is how to put a "simple" dot, or a vertical line, on a Chart.js bar chart where the dot has a dynamical value for the X axis -> [dynamic value, 0].
仅供参考——大约Expected value美元