change chart.js size - Javascript Chart.js

Javascript examples for Chart.js:Chart Configuration

Description

change chart.js size

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

section {//w w  w. ja v  a2s  .  c  o m
   width: 50%;
}


      </style> 
      <script type="text/javascript">
    window.onload=function(){
var canvas = document.getElementById('updating-chart'),
    ctx = canvas.getContext('2d'),
    startingData = {
      labels: ["A", "B", "C", "D"],
      datasets: [
          {
             label: "Product A",
             fillColor: "rgba(220,220,220,0.5)",
             strokeColor: "rgba(220,220,220,0.8)",
              pointColor: "rgba(220,220,220,1)",
              pointStrokeColor: "#fff",
              data: [65, 59, 80, 81]
          }
      ]
    };
var myLiveChart = new Chart(ctx,{
  type: 'bar',
  data: startingData,
  responsive: true,
  maintainAspectRatio: true
});
    }

      </script> 
   </head> 
   <body> 
      <section> 
         <canvas id="updating-chart" width="200" height="200"></canvas> 
      </section>  
   </body>
</html>

Related Tutorials