Javascript examples for highcharts:Column Chart
Stack Column Sum Positive and Negative Together
<html> <head> <title>Highcharts Demo</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> $(function () {//from w ww. j av a2 s . c om var cDiv= $('#container').highcharts(); $('#container').highcharts({ chart: { type: 'column' }, xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, yAxis: { stackLabels: { enabled: true, align: 'center', formatter: function() { var sum = 0; var series = this.axis.series; for (var i in series) { if (series[i].visible && series[i].options.stacking == 'normal' && this.x in series[i].yData) sum += series[i].yData[this.x]; } if (sum >= 0 && this.isNegative == false || sum < 0 && this.isNegative == true) { return Highcharts.numberFormat(sum,1); } else { return ''; } } } }, plotOptions: { column: { stacking: 'normal', pointPadding: 0, groupPadding: 0, dataLabels: { enabled: false, color: '#FFFFFF' } } }, series: [{ data: [29.9, -71.5, 106.4, -129.2, 144.0, -176.0, 135.6, 148.5, 216.4, 194.1, -95.6, 54.4] }, { data: [144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, -106.4, 129.2] }, { data: [55.9, 90.5, 106.4, 350.2, 144.0, 52.0, 130.6, 148.5, 216.4, 194.1, -95.6] }] }); }); </script> </head> <body> <div id="container" style="height: 400px"></div> <script src="https://code.highcharts.com/highcharts.js"></script> </body> </html>