forked from Technigo/project-github-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchart.js
More file actions
59 lines (56 loc) · 1.39 KB
/
Copy pathchart.js
File metadata and controls
59 lines (56 loc) · 1.39 KB
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
53
54
55
56
57
58
59
//DOM-selector for the canvas 👇
const ctx = document.getElementById("chart").getContext("2d");
const plugin = {
id: "custom_canvas_background_color",
beforeDraw: (chart) => {
const ctx = chart.canvas.getContext("2d");
ctx.save();
ctx.globalCompositeOperation = "destination-over";
ctx.fillStyle = "rgb(189,219,227)";
ctx.fillRect(0, 0, chart.width, chart.height);
ctx.restore();
},
};
//"Draw" the chart here 👇
const drawChart = (amount) => {
const config = {
type: "polarArea",
data: {
labels: [
"Finished Projects",
"Projects Left",
"Individual Projects",
"Team Projects",
],
datasets: [
{
label: "My First Dataset",
data: [amount, 19 - amount, amount - 4, amount - 2],
backgroundColor: [
"rgb(255, 99, 132)",
"rgb(75, 192, 192)",
"rgb(247,226,0)",
"rgb(84,81,185)",
],
},
],
},
options: {
plugins: {
title: {
display: true,
text: "My Github Repositories",
color: "#138",
font: {
size: 25,
},
},
},
responsive: true,
borderColor: "#d32",
color: "#138",
},
plugins: [plugin],
};
const myChart = new Chart(ctx, config);
};