Atmos
Search…
Chartjs
Chartjs simple yet flexible JavaScript charting for designers & developers.

Step 1

1
<script src="assets/vendor/chartjs/Chart.bundle.min.js" type="text/javascript"></script>
Copied!

Step 2

Add canvas tag for chartjs DOM element
1
<canvas id="myChart" width="400" height="400"></canvas>
Copied!

Step 3

Initialize charts
1
var ctx = document.getElementById("myChart").getContext('2d');
2
var myChart = new Chart(ctx, {
3
type: 'bar',
4
data: {
5
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
6
datasets: [{
7
label: '# of Votes',
8
data: [12, 19, 3, 5, 2, 3],
9
backgroundColor: [
10
'rgba(255, 99, 132, 0.2)',
11
'rgba(54, 162, 235, 0.2)',
12
'rgba(255, 206, 86, 0.2)',
13
'rgba(75, 192, 192, 0.2)',
14
'rgba(153, 102, 255, 0.2)',
15
'rgba(255, 159, 64, 0.2)'
16
],
17
borderColor: [
18
'rgba(255,99,132,1)',
19
'rgba(54, 162, 235, 1)',
20
'rgba(255, 206, 86, 1)',
21
'rgba(75, 192, 192, 1)',
22
'rgba(153, 102, 255, 1)',
23
'rgba(255, 159, 64, 1)'
24
],
25
borderWidth: 1
26
}]
27
},
28
options: {
29
scales: {
30
yAxes: [{
31
ticks: {
32
beginAtZero:true
33
}
34
}]
35
}
36
}
37
});
Copied!
Last modified 2yr ago
Copy link