首页 > 解决方案 > ChartJS Annotations 显示自定义标签

问题描述

有什么方法可以在鼠标悬停 chartJS 注释上显示自定义标签,就像在 ChartJS 上显示的那样?例如,当您创建点线图并悬停其中一个点时,它会显示该点的标签。我想要类似的东西,但在注释上。

标签: javascriptchart.jschartjs-plugin-annotation

解决方案


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


推荐阅读