Highcharts Demo

author(s): Torstein Hønsi

by prathik

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>

<div id="container" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div>

JavaScript

Highcharts.chart('container', {
    chart: {
        type: 'bar'
    },
    title: {
        text: 'Stacked bar chart'
    },
    xAxis: {
        categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
    },
    yAxis: {
        min: 0,
        title: {
            text: 'Total fruit consumption'
        }
    },
    legend: {
        reversed: true
    },
    plotOptions: {
        series: {
            stacking: 'normal'
        }
    },
    series: [{
        name: 'John',
        data: [{name: 'Apples', y: 5}, {name: 'Oranges', y: null}, {name: 'Pears', y: 4}, {name: 'Grapes', y: 7}, {name: 'Bananas', y: 2}]
    }, {
        name: 'Jane',
        data: [{name: 'Apples', y: 2}, {name: 'Oranges', y: 2}, {name: 'Pears', y: 3}, {name: 'Grapes', y: 2}, {name: 'Bananas', y: 1}]
    }, {
        name: 'Joe',
        data: [{name: 'Apples', y: 3}, {name: 'Oranges', y: 4}, {name: 'Pears', y: 4}, {name: 'Grapes', y: 2}, {name: 'Bananas', y: 5}]
    }, {
        name: 'abc',
        data: [{name: 'Apples', y: -3}, {name: 'Oranges', y: 5}, {name: 'Pears', y: 1}, {name: 'Grapes', y: 6}, {name: 'Bananas', y: 9}]
    }]
});