ChartJS row size settings - Javascript Chart.js

Javascript examples for Chart.js:Chart Configuration

Description

ChartJS row size settings

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.6.0/Chart.min.js"></script> 
      <style id="compiled-css" type="text/css">

.chartContainer {//from  ww  w .  ja v a 2  s .c  om
   position: relative;
   width: 502px;
}


      </style> 
      <script type="text/javascript">
    window.onload=function(){
var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
  type: 'horizontalBar',
  data: {
    labels: [
      ['Label_1_Line_1', 'Label_1_Line_2', 'Label_1_Line_3'],
      ['Label_2_Line_1', 'Label_2_Line_2', 'Label_2_Line_3'],
      ['Label_3_Line_1', 'Label_3_Line_2', 'Label_3_Line_3'],
      ['Label_4_Line_1', 'Label_4_Line_2', 'Label_4_Line_3'],
      ['Label_5_Line_1', 'Label_5_Line_2', 'Label_5_Line_3'],
      ['Label_6_Line_1', 'Label_6_Line_2', 'Label_6_Line_3'],
      ['Label_7_Line_1', 'Label_7_Line_2', 'Label_7_Line_3'],
    ],
    datasets: [{
      label: "My First dataset",
      backgroundColor: 'rgb(255, 99, 132)',
      borderColor: 'rgb(255, 99, 132)',
      data: [0, 10, 5, 2, 20, 30, 45],
    }]
  },
  options: {
     scales: {
       yAxes: [{
         maxBarThickness : 30
      }]
    }
  }
});
    }

      </script> 
   </head> 
   <body> 
      <div class="chartContainer"> 
         <canvas id="myChart"></canvas> 
      </div>  
   </body>
</html>

Related Tutorials