Chartjs to have a static scale for y-axis - Javascript Chart.js

Javascript examples for Chart.js:Axis

Description

Chartjs to have a static scale for y-axis

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://rawgit.com/nnnick/Chart.js/f3eb6f4a433b4f34a582842dcf7b42f710861a7d/Chart.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*from  ww  w.j a va 2 s. c o m*/
var lineChartData = {
    labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
    datasets: [{
        label: "My First dataset",
        data: [1, 8, 3, 4, 2, 3, 4],
    }]
};
var ctx = document.getElementById("chart").getContext("2d");
var myChart = new Chart(ctx, {
    type: "line",
    data: lineChartData,
    options: {
        scales: {
            yAxes: [{
                override: {
                    stepWidth: 20,
                    start: 0,
                    steps: 10
                }
            }]
        }
    }
});
    }

      </script> 
   </head> 
   <body> 
      <canvas id="chart" height="450" width="650"></canvas>  
   </body>
</html>

Related Tutorials