Unable to make y-axis to begin at zero in bar chart - Javascript Chart.js

Javascript examples for Chart.js:Bar Chart

Description

Unable to make y-axis to begin at zero in bar chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.js"></script> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.4/Chart.min.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/* w w w  .  ja v a  2s . c o  m*/
var simpleChart = new Chart($('#chart'), {
  type: 'bar',
  data: {
    labels: ['Online', 'Offline'],
    datasets: [{
      label: "# of servers",
      data: [1, 7],
      backgroundColor: [
        '#009245',
        '#c02a31'
      ]
    }]
  },
  options: {
    title: {
      display: false
    },
    scales: {
      yAxes: [{
         ticks: {
           beginAtZero: true
        }
      }]
    }
  }
});
    });

      </script> 
   </head> 
   <body> 
      <canvas id="chart"></canvas>  
   </body>
</html>

Related Tutorials