我使用click事件在折线图上打开一个自定义工具提示,大多数情况下它工作得很好,但有时点上的单击不起作用。
这是我的代码:
this.myChart = new Chart(myChartRef, {
type: "line",
data: {
labels: label,
datasets: dados,
},
options: {
elements: {
line: {
fill: false,
tension: 0
},
},
events: ["click"],
tooltips: {
mode: 'nearest',
intersect: true,
position: 'custom',
enabled: false,
animationDuration: 0,
custom: this.myChartTooltip()
},
hover: {
mode: 'x'
}
}
})发布于 2020-02-29 23:16:38
对于tooltips.mode: 'nearest',Chart.js文档声明:
如果intersect为true,则仅当鼠标位置与图形中的项目相交时才会触发
。
尝试设置intersect: false或定义更合适的interaction mode (即'x')
https://stackoverflow.com/questions/60457063
复制相似问题