-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchart.js
52 lines (46 loc) · 1.13 KB
/
chart.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
let ctx = document.getElementById('myChart').getContext('2d');
let labels = ['Science', 'Arts', 'Commerce'];
let colorHex = ['#FB3640', '#EFCA08', '#43AA8B'];
var b = localStorage.getItem("science");
var c = localStorage.getItem("bio");
var d = localStorage.getItem("commerce");
// alert("the value received is"+b);
// alert("the value received is"+c);
// alert("the value received is"+d);
let myChart = new Chart(ctx, {
type: 'pie',
data: {
datasets: [{
data: [b,c,d],
backgroundColor: colorHex
}],
labels: labels
},
options: {
responsive: true,
legend: {
position: 'bottom'
},
plugins: {
datalabels: {
color: '#fff',
anchor: 'end',
align: 'start',
offset: -10,
borderWidth: 2,
borderColor: '#fff',
borderRadius: 25,
backgroundColor: (context) => {
return context.dataset.backgroundColor;
},
font: {
weight: 'bold',
size: '10'
},
formatter: (value) => {
return value + ' %';
}
}
}
}
})