title: How to use Chart.js in Nodejs?
body: <p>How to create a pie chart using NodeJs with <code>chartjs</code>?
  want to create different types of charts using <code>chartjs</code> but when I tried to run the code shows "cannot set the property of width"</p>
  
  <pre><code>TypeError: Cannot set property 'width' of undefined
      at ni.resize (node_modules\chart.js\dist\Chart.min.js:7:93312)
      at ni.initialize (node_modules\chart.js\dist\Chart.min.js:7:92818)
      at ni.construct (node_modules\chart.js\dist\Chart.min.js:7:92559)
      at new ni (node_modules\chart.js\dist\Chart.min.js:7:91964)
      at Object.&lt;anonymous&gt; (chartjs\chart.js:7:15)
      at Module._compile (internal/modules/cjs/loader.js:778:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
      at Module.load (internal/modules/cjs/loader.js:653:32)
      at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
      at Function.Module._load (internal/modules/cjs/loader.js:585:3)
  </code></pre>
  
  <p>I tried to run this code to produce a pie chart image but found this error.</p>
  
  <pre><code>let Canvas = require("canvas"),
    canvas = Canvas.createCanvas(400, 400),
    ctx = canvas.getContext("2d"),
    Chart = require('chart.js'),
    fs = require("fs");
  
  var myChart = new Chart(ctx, {
    type: "pie",
    data: {
      labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
      datasets: [
        {
          label: "# of Votes",
          data: [12, 19, 3, 5, 2, 3],
          backgroundColor: [
            "rgba(255, 99, 132, 0.2)",
            "rgba(54, 162, 235, 0.2)",
            "rgba(255, 206, 86, 0.2)",
            "rgba(75, 192, 192, 0.2)",
            "rgba(153, 102, 255, 0.2)",
            "rgba(255, 159, 64, 0.2)"
          ],
          borderColor: [
            "rgba(255, 99, 132, 1)",
            "rgba(54, 162, 235, 1)",
            "rgba(255, 206, 86, 1)",
            "rgba(75, 192, 192, 1)",
            "rgba(153, 102, 255, 1)",
            "rgba(255, 159, 64, 1)"
          ],
          borderWidth: 1
        }
      ]
    },
    options: {
      scales: {
        yAxes: [
          {
            ticks: {
              beginAtZero: true
            }
          }
        ]
      }
    }
  });
  
  canvas.toBuffer(function(err, buf) {
    if (err) throw err;
    fs.writeFileSync("chart.png", buf);
  });
  </code></pre>
  
  <p>Should be an image in the current folder</p>