Stack a full series in Bar chart - Javascript highcharts

Javascript examples for highcharts:Bar Chart

Description

Stack a full series in Bar chart

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.11.0.js"></script> 
      <script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){//  ww w .  ja v  a  2 s. c  o m
$(function () {
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Stacked bar chart'
        },
        xAxis: {
            categories: ['Views', 'Value'],
            type: 'category'
        },
        yAxis: [{
            min: 0,
            title: {
                text: 'Value (?)'
            }
        },{
            min: 0,
            opposite: true,
            title: {
                text: 'Views'
            }
        }],
        legend: {
            reversed: true
        },
        plotOptions: {
            series: {
                stacking: 'normal'
            }
        },
        series: [{
            id: 'e3',
            name: 'Event 3',
            data: [{
                name: 'Views',
                y: 500
            }],
            yAxis: 1
        },{
            id: 'e2',
            name: 'Event 2',
            data: [{
                name: 'Views',
                y: 200
            }],
            yAxis: 1
        },{
            id: 'e1',
            name: 'Event 1',
            data: [{
                name: 'Views',
                y: 150
            }],
            yAxis: 1
        }, {
            linkedTo: 'e3',
            name: 'Event 3',
            data: [{
                x: 1,
                name: 'Value',
                y: 1000
            }]
        },{
            linkedTo: 'e2',
            name: 'Event 2',
            data: [{
                x: 1,
                name: 'Value',
                y: 2000
            }]
        },{
            linkedTo: 'e1',
            name: 'Event 1',
            data: [{
                x: 1,
                name: 'Value',
                y: 1500
            }]
        }]
    });
});
    });

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

Related Tutorials