1//in terminal:
2yarn add chart.js // or npm install chart.js if you use npm
3//html file:
4<canvas id="my-chart" width="400" height="400"></canvas>
5//js file
6import Chart from 'chart.js'
7
8const ctx = document.getElementById('my-chart').getContext('2d');
9const chart = new Chart(ctx, {
10 // The type of chart we want to create
11 type: 'bar',
12
13 // The data for our dataset
14 data: {
15 labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
16 datasets: [{
17 label: 'My First dataset',
18 backgroundColor: 'rgb(255, 99, 132)',
19 borderColor: 'rgb(255, 99, 132)',
20 data: [0, 10, 5, 2, 20, 30, 45]
21 }]
22 },
23
24 // Configuration options go here
25 options: {}
26 });
27};