[英]How to add cursor pointer to Chart.js datalabels plugin
I'm using ChartJs and datalabels plugin. 我正在使用ChartJs和datalabels插件。
I would like to add the css "cursor:pointer" when a user is hovering on a datalabel. 当用户将鼠标悬停在数据标签上时,我想添加css“cursor:pointer”。
How could I do that ? 我怎么能这样做?
I had to add this in the datalabels section 我不得不在datalabels部分添加它
It selects the chart when hovering on a specific label and changes the cursor to pointer. 它在悬停在特定标签上时选择图表并将光标更改为指针。 It resets when stopping from hovering the label:
当停止悬停标签时,它会重置:
listeners: {
enter: function(context) {
context.hovered = true;
var el = document.getElementById("myLineChart");
el.style.cursor = "pointer";
return true;
},
leave: function(context) {
context.hovered = false;
var el = document.getElementById("myLineChart");
el.style.cursor = "default";
return true;
},
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.