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
84 lines (81 loc) · 2.16 KB
/
Copy pathchart.js
File metadata and controls
84 lines (81 loc) · 2.16 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const ctx = document.getElementById('progressChart').getContext('2d');
// function to draw the Progress Chart, we have passed in amount of repos as an argument
const drawProgressChart = (amountOfRepos) => {
const data = {
labels: ['Finished Projects', 'Unfinished Projects'],
datasets: [
{
label: 'Technigo boot camp projects',
data: [amountOfRepos, 19 - amountOfRepos],
// length of the repo array, total 19 projects minus length of the repo array
backgroundColor: ['rgb(255, 99, 132)', 'rgb(255, 205, 86)'],
hoverOffset: 4,
},
],
};
const config = {
type: 'doughnut',
data: data,
options: {
plugins: {
legend: {
labels: {
color: 'white',
font: {
size: 12,
},
},
},
},
},
};
const progressChart = new Chart(ctx, config);
};
// function to draw the Language Chart with three arguments
const drawLanguagesChart = (html_percent, css_percent, js_percent) => {
// put the variable for the second canvas here because
// the id="languageChart" hasn't been created yet because of innerHTML in script.js
// if we put it at start of the chart.js, we wouldn't know what languageChart is
const ctx_languages = document.getElementById('languagesChart');
const data_2 = {
labels: ['HTML', 'CSS', 'Javascript'],
datasets: [
{
label: 'Language use (percentage)',
data: [html_percent, css_percent, js_percent],
backgroundColor: [
'rgb(255, 159, 64)',
'rgb(128, 0, 128)',
'rgb(255, 205, 86)',
],
borderColor: [
'rgba(255, 159, 64, 0.2)',
'rgb(128, 0, 128, 0.2)',
'rgba(255, 205, 86, 0.2)',
],
borderWidth: 2,
},
],
};
const stackedBar = new Chart(ctx_languages, {
type: 'bar',
data: data_2,
options: {
scales: {
y: {
beginAtZero: true,
},
},
plugins: {
legend: {
labels: {
color: 'black',
font: {
size: 12,
},
},
},
},
},
});
};