Home Forums Chart Support Question: How to toggle series using the legend Reply To: Question: How to toggle series using the legend


workaround for this could be to add a event handler.. i added a click event to hide data series as below.
works but there are event collisions and it appears that the tooltip is using a “previousDataPointEventObject” object which gets lost when i ravage the data object. this makes the errors stack up pretty quick but is effective until i figure out how to reset the previousDataPoint

//appending series
              type: 'spline',
              dataPoints: x.data[key],
              click: seriesToggle,
              showInLegend: true,
              toolTipContent: "<b>{name}</b><br>{x}: {y}",
              name: key,
              legendText: key

  function seriesToggle(e){
    if(chart.options.data.length == 1){//restore..
      chart.options.data = data.chart;
      data.chart = [];//clear backup
    } else {
      var series = e.dataSeries.name;
      data.chart = chart.options.data;//backup data
      for(var i in data.chart){
        if(data.chart[i].name == series){
          chart.options.data = [ data.chart[i] ]; //only show clicked series