Automatic scaling not starting at zero

Hi, I have the following code for a bar chart that has a very simple data set of integers:

<html>
  <head>
    <title>ChartJs Test</title>
    <script src="http://www.chartjs.org/dist/2.6.0/Chart.bundle.js"></script>
  </head>

  <body>
      <div style="width: 75%%">
        <canvas id="canvas"></canvas>
      </div>

      <script>
        var barChartData = {
          labels: ["January", "February", "March"],
          datasets: [{
            label: 'Dataset 1',
            data: [2, 3, 1]
          }]
        };

        window.onload = function() {
          var ctx = document.getElementById("canvas").getContext("2d");

          window.myBar = new Chart(ctx, {
            type: "bar",
            data: barChartData
          });
        };

      </script>
  </body>
</html>

You can see in the js fiddle that there are two visual issues. Firstly the scale does not start at zero giving a false impression of the data, and also the scale on the left has decimals places even though the data is only integers. Why is this? Am I missing something? Cheers

Author: Fantashit

2 thoughts on “Automatic scaling not starting at zero

Comments are closed.