Move Chart.js legend to bottom - Javascript Chart.js

Javascript examples for Chart.js:Legend

Description

Move Chart.js legend to bottom

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>chart.js 2.0 bar</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){//from   w w w .  ja  va  2  s  . c  om
var canvas = document.getElementById('myChart');
var data = {
  labels: ["January", "February", "March", "April", "May", "June", "July"],
  datasets: [{
    label: "My First dataset",
    data: [65, 59, 20, 81, 56, 55, 40],
  }]
};
Chart.Bar(canvas, {
  data: data,
  options: {
    legend: {
      position: "bottom"
    }
  }
});
    }

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

Related Tutorials