Search code examples
javascriptchartshighchartsdrilldown

Enable Drilldown in highchart without modifying the series


I want to enable drilldown in highcharts, but my constraint is that I can't modify the data in the "series" property of chart. Hence I can't have the "drilldown" property set to true/any value for any item in the series.

I have tried defining "events" property in the "chart" Object. But that doesn't seem to work until and I unless I specify "drilldown" property to true for the items in the series options.

So is there a way to enable/set drilldown property to true for the chart without modifying my series? My series would just have the array of name/value pair and NO other properties.


Solution

  • You could utilize the Chart.addSeriesAsDrilldown (API) method to achieve something like this.

    For example, your click listener could be:

    plotOptions: {
        series: {
            point: {
                events: {
                    click: function(e) {
                        $('#container').highcharts()
                                .addSeriesAsDrilldown(this, { data: [1,2,3] });
                    }
                }
            }
        }
    }
    

    See this JSFiddle for a demonstration.