Enforce 0 on axis in bubble charts - Javascript highcharts

Javascript examples for highcharts:Bubble Chart

Description

Enforce 0 on axis in bubble charts

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Bubble chart Zero</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 w w.  j  av a  2  s  .  c om*/
    $('#container').highcharts({
        chart: {
            type: 'bubble'
        },
        yAxis: {
            tickPositioner: function () {
                var positions = [],
                    min = Math.floor(this.min / 10) * 10,
                    max = Math.ceil(this.max / 10) * 10,
                    step = 20,
                    tick;
                if (min > 0)
                    min = 0;
                tick = min;
                while (tick < max + step) {
                    positions.push(tick);
                    tick += step;
                }
                return positions;
            }
        },
        series: [{
            data: [
                [1, 100, 5000],
                [50, 50, 2500],
                [1, 50, 1]
            ]
        }
]
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/highcharts-more.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="height: 600px; width: 600px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials