Chart js to change value for Y Axis - Javascript Chart.js

Javascript examples for Chart.js:Axis

Description

Chart js to change value for Y Axis

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head> 
      <title>Stacked Horizontal Charts with Chart.js</title> 
   </head> 
   <body translate="no">   
      <div class="graph_container"> 
         <canvas id="myChart" width="400" height="400"></canvas> 
      </div>   
      <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.js"></script> 
      <script>
      var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {//from www  .jav a2 s  . c  om
    type: 'bar',
    data: {
        labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
        datasets: [{
            label: '# of Votes',
            data: [12, 19, 3, 5, 2, 3],
            backgroundColor: [
                'rgba(255, 99, 132, 0.2)',
                'rgba(54, 162, 235, 0.2)',
                'rgba(255, 206, 86, 0.2)',
                'rgba(75, 192, 192, 0.2)',
                'rgba(153, 102, 255, 0.2)',
                'rgba(255, 159, 64, 0.2)'
            ],
            borderColor: [
                'rgba(255,99,132,1)',
                'rgba(54, 162, 235, 1)',
                'rgba(255, 206, 86, 1)',
                'rgba(75, 192, 192, 1)',
                'rgba(153, 102, 255, 1)',
                'rgba(255, 159, 64, 1)'
            ],
            borderWidth: 1
        }]
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero:true
                },
                afterTickToLabelConversion : function(q){
                    for(var tick in q.ticks){
                      q.ticks[tick] += '\u00B0C';
                    }
                }
            }]
        }
    }
});
      </script>  
   </body>
</html>

Related Tutorials