Javascript examples for highcharts:Chart Axis
Zero Centered on Y-Axis with Negative Values in area chart
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript"> $(function () {//from w w w. ja va 2s.co m $('#container').highcharts({ chart: { type: 'area' }, title: { text: 'Area chart with negative values' }, yAxis: { }, credits: { enabled: false }, series: [{ name: 'Joe', data: [-2, -2, -1, 0, 1, 2, 2, 3, 5, 6, 7, 5, 3, 2, 1, 0, -1 -2, -1, 0] }] },function(chart) { var dExt; var ext = chart.yAxis[0].getExtremes(); var dMax = Math.abs(ext.dataMax); var dMin = Math.abs(ext.dataMin); dMax >= dMin ? dExt = dMax : dExt = dMin; var min = 0 - dExt; chart.yAxis[0].setExtremes(min, dExt); }); }); </script> </head> <body> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div> </body> </html>