chart.js - ChartJs 注释不适用于 Tooltip
问题描述
我有一个要求,在悬停时我需要显示一条水平线,如下面的小提琴。但是一旦绘制悬停水平线,工具提示就会消失。任何人都可以帮助我如何获得工具提示和水平线。
请注意,在下面的小提琴中,我们在悬停时遇到问题,这需要时间,但在我的实际项目中,悬停工作正常,我只是遇到悬停后工具提示在一段时间后不起作用的问题。 https://jsfiddle.net/h8ow63be/
var option = {
legend: false,
title: {
display: true,
},
onHover: function(evt) {
var item = myLineChart.getElementAtEvent(evt);
if (item.length) {
updateChart(data.datasets[0].data[item[0]._index].y)
}
},
animation: {
duration: 0
},
annotation: {
annotations: lines
},
scales: {
xAxes: [{
id: 'x-axis',
type: 'linear',
position: 'bottom',
ticks: {
max: 12,
min: 1,
stepSize: 1
}
}],
yAxes: [{
id: 'y-axis',
type: 'linear',
}],
}
};
解决方案
推荐阅读
- python - 我可以用字母替换字符串中的某个位置吗?
- python - 使功能无需全局导入即可使用
- angular - Angular 8 - 路由路径参数的值必须匹配字符串列表
- javascript - 点击打开卡片以显示更多详细信息
- python - 使用 for 循环在 Python 中将向量转换为矩阵
- database - 使用 sqlite 在 VB.Net 窗体中搜索功能
- python - Pygame 对象没有属性“rect”(pygame)
- python - Matplotlib 中带有对数刻度的小刻度
- html - 有没有办法得到类属性应用于不同的元素?
- python - 如何使用空格拟合字符串,最小化编辑距离?