Javascript examples for highcharts:Column Chart
labels in column chart with negative values
<html> <head> <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"> $(window).load(function(){/*from w ww .j av a 2s .c o m*/ $(function () { $('#container').highcharts({ chart: { type: 'column', animation: false, events: { load: function(){ var chart = this, cols = chart.series[0], stacks = chart.yAxis[0].stacks, i, j; for(i in stacks){ var stack = stacks[i]; for(j in stack){ var label = stack[j].label, labelBB = label.getBBox(), diff = labelBB.y - labelBB.height; if(diff < 0) { label.attr({ translateY: - diff }) } } } } } }, title: { text: null }, xAxis: { categories: ['Category 1', 'Category 2', 'Category 3'], labels: { style: { fontSize: '1.2em' } } }, yAxis: { allowDecimals: false, title: { text: '' }, labels: { formatter: function () { return this.value === 0 ? '0% (Index)' : this.value + '%'; }, style: { color: '#4572A7' } }, stackLabels: { enabled: true, style: { color: 'black', fontSize: '1.2em' }, formatter: function () { return this.stack + ((this.total && this.total != 0) ? ': ' + Math.round(this.total).toFixed(0) + '%' : ''); }, rotation: -90, x: -5, verticalAlign: 'bottom', align: 'left', textAlign: 'left' } }, plotOptions: { column: { stacking: 'normal', pointPadding: 0.3 }, series: { shadow: false, animation: false } }, tooltip: { enabled: false }, legend: { borderWidth: 1, shadow: false }, series: [{ data: [34, 64, -443], stack: 'Stack 1' }] }); }); }); </script> </head> <body> <script src="https://code.highcharts.com/highcharts.js"></script> <div id="container" style="height: 400px"></div> </body> </html>