chart.js npm code example
Example 1: install package chart.js
npm install chart.js --save
Example 2: chart.js npm install
npm install chart.js --save
Example 3: chart.js
yarn add chart.js
<canvas id="my-chart" width="400" height="400"></canvas>
import Chart from 'chart.js'
const ctx = document.getElementById('my-chart').getContext('2d');
const chart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
label: 'My First dataset',
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: [0, 10, 5, 2, 20, 30, 45]
}]
},
options: {}
});
};