Chart.js beginAtZero usage - Javascript Chart.js

Javascript examples for Chart.js:Chart Configuration

Description

Chart.js beginAtZero usage

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>chart.js 2.0 bar</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*ww  w  .j  av a2 s  .  c o  m*/
var chartdata = {
  labels: ["January", "February", "March"],
  datasets: [{
    label: 'Count',
    backgroundColor: 'rgba(200, 200, 200, 0.75)',
    borderColor: 'rgba(200, 200, 200, 0.75)',
    hoverBackgroundColor: 'rgba(200, 200, 200, 1)',
    hoverBorderColor: 'rgba(200, 200, 200, 1)',
    data: [65, 59, 30],
  }]
};
var options = {
  scales: {
    yAxes: [{
      ticks: {
        beginAtZero: true
      }
    }]
  }
}
var ctx = document.getElementById('mycanvas');
var barGraph = Chart.Bar(ctx, {
  data: chartdata,
  options: options
});
    }

      </script> 
   </head> 
   <body> 
      <canvas id="mycanvas" width="100"></canvas>  
   </body>
</html>

Related Tutorials