javascript - 当鼠标悬停在 Highcharts 中时隐藏折线图

标签 javascript charts highcharts

我使用 higchart 绘制了两条线,当用户将鼠标悬停在绘图区域时,我需要隐藏一条线。谁能帮我这个。 下面是我尝试过的 JSFiddle 链接。

JSFiddle link

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container" style="height: 400px"></div>

Javascript

Highcharts.chart('container', {
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },
    plotOptions: {
        series: {
            point: {
                events: {
                    mouseOver: function () {
                       console.log("mouse over");
                    }
                }
            },
            events: {
                mouseOut: function () {
                   console.log("mouse out");
                }
            }
        }
    },
series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
        visible: true
    }, {
        data: [144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2]
    }]
});

最佳答案

您可以在 mouseOver 事件中对特定系列使用隐藏方法。

events: {
  mouseOver: function() {
    this.hide();
  }
}

现场演示:https://jsfiddle.net/BlackLabel/ynq7fobe/

API:https://api.highcharts.com/class-reference/Highcharts.Series#hide

关于javascript - 当鼠标悬停在 Highcharts 中时隐藏折线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51321654/

相关文章:

javascript - 按类别切换可见性

Javascript 数据格式,这是 JSON 吗?

javascript - 合并 Javascript 对象

android - 最好的可定制Android图表库

javascript - 从 highcharts 中删除周末

javascript - 列上方的动态值 + jQuery Highcharts

javascript - jquery 删除包含特定单词的类

javascript - Angularjs 和谷歌图表 API : chart type is not defined

javascript - 使用 Highcharts 和 MySQL 数据库中的数据进行动态图表

r - 如何从 RStudio 中的查看器将绘图保存为磁盘上的图像?