ChartJS: two axes in horizontal Bar chart - Javascript Chart.js

Javascript examples for Chart.js:Bar Chart

Description

ChartJS: two axes in horizontal Bar chart

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.5.0/Chart.bundle.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){//from   ww w.  ja  v  a2 s  .  c om
var data = {
labels: ["Label1", "Label2", "Label3", "Label4", "Label5"],
datasets: [
{
   "label": "Total V",
   "yAxisID": "A",
   "backgroundColor": "rgba(53,81,103,1)",
   "borderColor": "rgba(53,81,103,.4)",
   "data": [100,90,80,70,60]
},
{
   "label": "Total C",
   "yAxisID": "A",
   "backgroundColor": "rgba(255,153,0,1)",
   "borderColor": "rgba(255,153,0,.4)",
   "data": [10,9,8,7,6]
}]};
var options =  {
    scales: {
      yAxes: [{
        id: 'A',
        position: 'left'
      }]
    }
  };
var ctx = document.getElementById("myChart");
new Chart(ctx, {type: "horizontalBar",data:data, options:options});
    }

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

Related Tutorials