Ashok Reddy
Ashok Reddy

Reputation: 1

disabling click event for a series highchart

I have a multiple line series highchart with markertip option enabled showing values for all the series. I want a click event enabled only for one series. The rest of the series click Event should be disabled. Thanks for the help

Ashok

Upvotes: 0

Views: 3844

Answers (1)

MorKadosh
MorKadosh

Reputation: 6006

Highcharts lets you add custom key value options to the chart objects. With that said, we can add a clickable key to any series we would like to allow clicking on, and by that distinguish the non-clickable serieses:

series:[
{
      name: 'Tokyo',
      clickable:true,
      data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
},
{
   name: 'New York',
   data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
} ],

After that, we can use plotOptions for capturing a series click event (note: from your question I understood that you are willing to make the whole series clickable (the lines between points too))

    plotOptions:{
        series:{
            events:{
                click: function(e){
                     //do something
                }
            }
        }
    },

And finally, we would like to perform the actions for the clickable series only:

plotOptions:{
    series:{
        events:{
            click: function(e){
               if(e.point.series.options.clickable)
                   alert('Works for Tokyo Only')
            }
        }
    }
},

Fiddle: http://jsfiddle.net/0tLh4ykg/1/

Upvotes: 1

Related Questions