Chartjs change horizontal axis value - Javascript Chart.js

Javascript examples for Chart.js:Axis

Description

Chartjs change horizontal axis value

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://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.bundle.js"></script> 
      <script type="text/javascript">
    window.onload=function(){//from  w  ww. j  a v a2 s  .co  m
var ctx = document.getElementById("myChart").getContext("2d");
var data = {
  labels: ["Chocolate", "Vanilla", "Strawberry"],
  datasets: [{
    label: "Blue",
    backgroundColor: "blue",
    data: [3, 7, 4]
  }, {
    label: "Red",
    backgroundColor: "red",
    data: [-4, -3, -5]
  }, {
    label: "Green",
    backgroundColor: "green",
    data: [-7, -2, -6]
  }]
};
var myBarChart = new Chart(ctx, {
  type: 'bar',
  data: data,
  options: {
    scales: {
      yAxes: [{
        ticks: {
          min: 2,
        }
      }]
    }
  }
});
    }

      </script> 
   </head> 
   <body> 
      <canvas id="myChart" width="400" height="400"></canvas>  
   </body>
</html>

Related Tutorials