yano3nora
8/29/2017 - 1:51 PM

[js: chart.js] Simple HTML5 Charts using the canvas-tag by native JS. - #js

[js: chart.js] Simple HTML5 Charts using the canvas-tag by native JS. - #js

OVERVIEW

References

Getting Started

http://www.chartjs.org/docs/latest/getting-started/installation.html

npm install chart.js --save
<canvas id="myChart"></canvas>
import Chart from 'chart.js';

var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
  type: 'line',
  data: {
    labels: ['M', 'T', 'W', 'T', 'F', 'S', 'S'],
    datasets: [{
      label: 'apples',
      data: [12, 19, 3, 17, 6, 3, 7],
      backgroundColor: "rgba(153,255,51,0.4)"
    }, {
      label: 'oranges',
      data: [2, 29, 5, 5, 2, 3, 10],
      backgroundColor: "rgba(255,153,0,0.4)"
    }]
  }
});

SAMPLE CODE