Enable Drilldown in highchart without modifying the series - Javascript highcharts

Javascript examples for highcharts:Chart Series

Description

Enable Drilldown in highchart without modifying the series

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript">
$(function () {/*from  w  w w .  ja  va2  s . com*/
    var data = [2, 5, 8];
    var drilldowns = [
        [1,2,3],
        [4,5,6],
        [7,8,9]
    ];
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        plotOptions: {
            series: {
                point: {
                    events: {
                        click: function(e) {
                            if(this.series.name == "Main")
                                $('#container').highcharts()
                                        .addSeriesAsDrilldown(this, { data: drilldowns[this.x] });
                        }
                    }
                }
            }
        },
        series: [{
            name: 'Main',
            data: data
        }]
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/drilldown.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials