如何仅为图形而不是标题和图例创建悬停事件?

这是我的配置:

var YEARS = ['2009', '2010', '2011', '2012', '2013', '2014', '2015','2016','2017','2018','2019'];
         config = {
            type: 'line',
//          responsive:true,
            data: {
                labels: ['2009', '2010', '2011', '2012', '2013', '2014', '2015','2016','2017','2018','2019'],
                datasets
            },
            options: {
                // responsive: true,
                // maintain
                responsive: true,
            maintainAspectRatio: false,
                stacked:false,
                title: {
                    display: true,
                    text: 'ROI History'
                },
                tooltips: {
                    mode: 'index',
                    intersect: false,
                    callbacks: {
               label: function(tooltipItem, data) {
                   return numberWithCommas(tooltipItem.yLabel)+"%" }, }
                },
                hover: {
                    mode: 'nearest',
                    intersect: true
                },

                scales: {
                    xAxes: [{
                        display: true,
                        scaleLabel: {
                            display: true,
                            labelString: 'Year'
                        }
                    }],
                    yAxes: [{
                        ticks:{
                           callback: function(value) {
                                return numberWithCommas(value) + "%"
                        }
                        },
                        display: true,
                        scaleLabel: {
                            display: true,
                            labelString: 'ROI'
                        },

                    }]
                }
            }
        };

当我将鼠标移到图例或标题上时,工具提示会四处移动。我希望它在离开图表时消失。我尝试过更改模式以将悬停设置为x轴,但这并没有改变任何内容。

任何帮助,将不胜感激!

评论