question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatic scaling not starting at zero

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
panzarinocommented, Jul 20, 2017

@burt202 You can add beginAtZero to your scales configuration, which will allow you to specify that the scale starts at 0. Here is an updated jsfiddle: https://jsfiddle.net/9bgeu5rx/1/

options: {
     scales: {
         yAxes: [{
             ticks: {
                 beginAtZero: true
             }
         }]
     }
 }
8reactions
afrazahmmadcommented, Nov 28, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot scaling issues with an Amazon EC2 Auto ... - AWS
Amazon EC2 Auto Scaling can't evaluate a CloudWatch scaling policy for suspended Terminate, Launch, or Alarm Notification processes.
Read more >
How To SET The Value of AxisY Starts from ZERO ... - Telerik
My requirement is The AxisY starts with Zero and want to enable the auto scaling or auto range is TRUE. Both are not...
Read more >
Auto-scale y-axis always defaults to zero - Mr. Excel
I'm graphing multiple stock charts. The auto-scale for the high works perfectly (if a stock reached, say, $50 over the past year, then...
Read more >
Can my auto scaling group have zero running instances? : r/aws
Set both Desired AND Minimum to zero. Desired in your case allows it to terminate all instances but if Min > 0 then...
Read more >
Auto-scaling your functions - OpenFaaS
But the function will not be set to zero yet, it will be brought up to the minimum range which is 1. Scaling...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found