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
125 lines (122 loc) · 3.71 KB
/
chart.js
File metadata and controls
125 lines (122 loc) · 3.71 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const reposChart = document.getElementById('reposChart').getContext('2d')
// global options for chart.js
Chart.defaults.font.family = 'Roboto'
Chart.defaults.font.size = 24
Chart.defaults.color = 'white'
const drawReposChart = (amount) => {
new Chart(reposChart, {
type: 'bar',
data: {
labels: ['Done', 'To do'],
datasets: [{
data: [
amount,
19 - amount
],
backgroundColor: [
'#DBE2EF',
'#3F72AF'
]
}]
},
options: {
indexAxis: 'y', // for horizontal bar graph instead of vertical
scales: {
y: {
grid: {
display: false, // removes grid lines for y axis
borderColor: 'white',
}
},
x: {
display: false, // removes x axis
}
},
plugins: {
title: {
display: true,
text: 'Technigo projects',
},
legend: {
display: false,
},
tooltip: {
backgroundColor: '#F9F7F7',
bodyColor: '#112D4E',
titleColor: '#112D4E',
titleAlign: 'center',
bodyAlign: 'center',
titleFont: {
size: 12,
weight: '700'
},
bodyFont: {
size: 12,
weight: '700'
},
cornerRadius: 2,
displayColors: false
}
}
}
})
}
const drawLanguagesChart = (html, css, js, idChart) => {
const languagesChart = document.getElementById(idChart).getContext('2d')
new Chart(languagesChart, {
type: 'polarArea',
data: {
labels: ['HTML', 'CSS', 'JS'],
datasets: [{
data: [
html,
css,
js
],
backgroundColor: [
'#DBE2EF',
'#3F72AF',
'#112D4E'
]
}
]
},
options: {
scales: {
r: {
ticks: {
display: false, // removes vertical numbers
// callback added because there is an issue with ticks, link: https://github.com/chartjs/Chart.js/issues/8092
callback: function (val, index) {
return val
},
},
grid: {
display: false // removes circular lines
}
}
},
plugins: {
title: {
display: false
},
legend: {
display: true,
position: 'top',
labels: {
color: '#112D4E',
usePointStyle: true,
pointStyle: 'rect',
font: {
size: 12
}
},
onClick: null, // removes on click event: not possible to strike through a label by clicking on it
},
tooltip: {
enabled: false,
}
}
}
})
}