Bar with negative stack

author(s): Torstein Hønsi

by AbhishekRohan

HTML

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


    <div id="container"></div>

JavaScript

// Data gathered from http://populationpyramid.net/germany/2015/

// Age categories
var categories= ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'];

Highcharts.chart('container', {
    chart: {
        type: 'bar',        
    },
    title: {
        text: ''
    },
    xAxis: {
        categories: categories,
        reversed: true,
        tickWidth : 0,
        
        lineColor : 'transparent',
        tickmarkPlacement : 'on',
						gridLineWidth : 1,
						lineWidth : 0,
						tickLength : 3,
						tickColor :"#ababab",
            tickPosition : "outside",
   					gridLineDashStyle: 'Dash',
   					gridLineColor : "#cccccc",
         		endOnTick: false,     
    },
    yAxis: {
    lineColor: "#cccccc",
    lineWidth : 0.5,
    gridLineWidth: 0,
		   plotLines: [{
            color: '#cccccc',
            width: 0.5,
            value: 0
        }]
    },

    plotOptions: {
    
        bar : {
        	  dataLabels: {
						         enabled: true,
                     x : 600,
                     align : "right",
                     y: -8,
								     style : {
											color : '#555555',
											fontSize : "12px",
											fontWeight : 'normal',
											textOverflow : 'none',
											whiteSpace : 'nowrap'
											
										}, formatter : function(){
						                		return this.y+"$";
						                },
						            },
        }
    },

    tooltip: {
  			enabled :false
    },

    series: [{
        data: [
            {y: 9.1}, {y : 20.0}, {y :12.1}, {y: 6.3}, {y: -6.6,color:"red"}
        ]
    }]
});