javascript - ChartJS Annotations 显示自定义标签
问题描述
有什么方法可以在鼠标悬停 chartJS 注释上显示自定义标签,就像在 ChartJS 上显示的那样?例如,当您创建点线图并悬停其中一个点时,它会显示该点的标签。我想要类似的东西,但在注释上。
解决方案
onHover API
options: {
// LOOK AT ME!!! I'M SO IMPORTANT!!!
onHover: function onHover (evt, activeElements) {
if (!activeElements || !activeElements.length) return;
// logic operation
this.update();
},
},
https://www.chartjs.org/docs/latest/configuration/legend.html
推荐阅读
- python - Django - 全球字典
- reactjs - 如何重置 WebStorm 中的设置?
- image - Go GC 似乎没有收集我未引用的指针以进行图像加载?
- r - 在函数中使用for循环,只返回最后一个值
- android - 为什么按意图发送内容不起作用
- python - 如何在 Windows 下的 Python 中将 emojis 渲染为图像?
- reactjs - 如果当前订阅未完成,则取消新订阅
- javascript - Webpack Encore - Vuejs 测试 Mocha
- python - 如何通过 ssh 访问本地服务器上的端口?
- c# - URL 重写不适用于 clickonce 应用程序的 http 到 https 重定向