lundi 24 avril 2017

Cannot change chart.js size

<html>
<head>
  <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="/css/graph2.css">
  <title>Graph</title>
  <script src="http://ift.tt/2c5hbLq"></script>

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

That is the html I am using and I am using Chart.js 2.1.4, but I am unable to reduce the size no matter what I do.

Javascript:

<script type="text/javascript">
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>

How can I fix this? I always a get a really big graph, covering the whole screen completely no matter what I change in the canvas HTML fields.

Help?




Aucun commentaire:

Enregistrer un commentaire