Prevent Area plot Y-axis from starting with ZERO in stock chart - Javascript highcharts

Javascript examples for highcharts:Chart Axis

Description

Prevent Area plot Y-axis from starting with ZERO in stock chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Stock 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 () {/*ww  w. ja v  a2 s .  co m*/
    var data = [[1375660800000, 106861],[1375747200000, 107397],[1375833600000, 108674],[1375920000000, 108792],[1376006400000, 110504],[1376265600000, 110658],[1376352000000, 110792],[1376438400000, 111095],[1376524800000, 112334],[1376611200000, 112775],[1376870400000, 113051],[1376956800000, 113426],[1377043200000, 113516]];
    $('#container').highcharts('StockChart', {
      series: [{
        type: 'area',
        data: data,
          threshold: null
      }],
        yAxis: {
            min: (function() {
                var min = data[0][1];
                for (var i = 0; i < data.length; i++) {
                    var value = data[i][1];
                     if (value < min) {
                       min = value;
                     }
                }
                return min;
            })()
        }
    });
});

      </script> 
   </head> 
   <body> 
      <div id="container" style="height: 400px; min-width: 600px"></div> 
      <script src="https://code.highcharts.com/stock/highstock.js"></script>  
   </body>
</html>

Related Tutorials