Create a chart with three values - Javascript Chart.js

Javascript examples for Chart.js:Chart Data

Description

Create a chart with three values

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="http://www.chartjs.org/assets/Chart.min.js"></script> 
      <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   ww  w.  ja  v a  2  s  . co m
var ctx = document.getElementById("myChart").getContext("2d");
var data = {
  labels: ["Jan", "Feb", "Mar"],
  datasets: [{
    label: "HPCL",
    backgroundColor: "skyblue",
    data: [20, 32, 12]
  }, {
    label: "FG ",
    backgroundColor: "maroon",
    data: [23, 10, 15]
  }, {
    label: "abcd",
    backgroundColor: "green",
    data: [13, 34, 16]
  }, {
    label: "test",
    backgroundColor: "violet",
    data: [12, 23, 16]
  }]
};
var myBarChart = new Chart(ctx, {
  type: 'bar',
  data: data,
  options: {
    barValueSpacing: 20,
    scales: {
      yAxes: [{
        ticks: {
          min: 0,
        }
      }]
    }
  }
});
    }

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

Related Tutorials