Jijo Cleetus
Jijo Cleetus

Reputation: 2867

hide a line chart while mouseover in highchart

I have plotted two lines using higchart and i need to hide one line when user mouse over in to the plotting area. can anyone help me with this. Below is the JSFiddle link i have tried.

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]
    }]
});

Upvotes: 0

Views: 347

Answers (1)

ppotaczek
ppotaczek

Reputation: 39139

You can use hide method on a specific series in mouseOver event.

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

Live demo: https://jsfiddle.net/BlackLabel/ynq7fobe/

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

Upvotes: 1

Related Questions