Highcharts Demo

author(s): Torstein Hønsi

by Rajan Paneru

HTML

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.src.js">


</script>
<script src="https://code.highcharts.com/modules/drilldown.src.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<br>
<button id="update">Update</button>
<br>
<br>

JavaScript

// Create the chart
var chart = Highcharts.chart('container', {
    chart: {
        type: 'column'
    },
    title: {
        text: 'Basic drilldown'
    },
    xAxis: {
        type: 'category'
    },

    legend: {
        enabled: false
    },

    plotOptions: {
        series: {
            borderWidth: 0,
            dataLabels: {
                enabled: true
            }
        }
    },

    series: [{
        name: 'Things',
        colorByPoint: true,
        data: [{
            name: 'Animals',
            y: 5,
            drilldown: 'animals'
        }, {
            name: 'Fruits',
            y: 2,
            drilldown: 'fruits'
        }, {
            name: 'Cars',
            y: 4,
            drilldown: 'cars'
        }]
    }],
    drilldown: {
        series: [{
            id: 'animals',
            data: [
                ['Cats', 4],
                ['Dogs', 2],
                ['Cows', 1],
                ['Sheep', 2],
                ['Pigs', 1]
            ]
        }, {
            id: 'fruits',
            data: [
                ['Apples', 4],
                ['Oranges', 2]
            ]
        }, {
            id: 'cars',
            data: [
                ['Toyota', 4],
                ['Opel', 2],
                ['Volkswagen', 2]
            ]
        }]
    }
});


$('#update').click(function() {
    chart.update({
        drilldown: {
            series: [{
                id: 'animals',
                data: [
                    ['Cats2', 6],
                    ['Dogs2', 7],
                    ['Cows2', 2],
                    ['Sheep2', 3],
                    ['Pigs2', 2]
                ]
            }, {
                id: 'fruits',
                data: [
                    ['Apples2', 5],
                    ['Oranges2', 3]
                ]
            }, {
                id: 'cars',
                data: [
                    ['Toyota2', 5],
                    ['Opel2', 3],
                   ...