-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode-chart.html
More file actions
176 lines (171 loc) · 4.99 KB
/
code-chart.html
File metadata and controls
176 lines (171 loc) · 4.99 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Code In / Code Out</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js"></script>
<style>
body { background: #1e1e2e; color: #cdd6f4; font-family: monospace; margin: 40px; }
h1 { font-size: 1.2rem; color: #cba6f7; margin-bottom: 4px; }
p { color: #6c7086; font-size: 0.8rem; margin-top: 0; margin-bottom: 24px; }
.chart-wrap { max-width: 900px; background: #181825; border-radius: 12px; padding: 28px; }
</style>
</head>
<body>
<h1>Code In / Code Out — JSHack</h1>
<p>Lines inserted vs. deleted per day across all commits</p>
<div class="chart-wrap">
<canvas id="chart"></canvas>
</div>
<script>
const labels = [
"Oct 15",
"Nov 1","Nov 2","Nov 3",
"Feb 7","Feb 8","Feb 9","Feb 10","Feb 11",
"Feb 12","Feb 13","Feb 14","Feb 15","Feb 16",
"Feb 17","Feb 18","Feb 19","Feb 20","Feb 21",
"Feb 22","Feb 23","Feb 24","Feb 26","Feb 27","Feb 28",
"Mar 1","Mar 2","Mar 3","Mar 5","Mar 6","Mar 7",
"Mar 8","Mar 9","Mar 11","Mar 12","Mar 13","Mar 14",
"Mar 15","Mar 16","Mar 17","Mar 18","Mar 19","Mar 20",
"Mar 21","Mar 22","Mar 23","Mar 24","Mar 25","Mar 26",
"Mar 27","Mar 28","Mar 29","Mar 30","Mar 31",
"Apr 1","Apr 2","Apr 3","Apr 4","Apr 5","Apr 6",
"Apr 7","Apr 8","Apr 9","Apr 10","Apr 11","Apr 12",
"Apr 13","Apr 14","Apr 15","Apr 16","Apr 17","Apr 18",
"Apr 19","Apr 20","Apr 21","Apr 22","Apr 23","Apr 24",
"Apr 25","Apr 26"
];
const inserted = [
3496,
1936,2373,2666,
3571,5453,5103,793,547,
2286,5842,7543,4070,3602,
619,3339,13708,3165,3888,
4599,3508,4122,4953,4478,1305,
2966,3250,248,562,4335,2933,
6531,5429,3468,5678,2737,4390,
3360,8366,1750,1657,3782,2625,
7735,5888,6906,3065,1544,3823,
4783,1532,1986,4622,3847,
13122,3859,6028,4509,6552,3570,
2622,815,6455,3742,3677,389,
2956,3717,654,1983,3166,1049,
640,2341,1708,213,2347,3309,
2950,181
];
const deleted = [
0,
807,640,148,
578,2174,143,55,90,
372,1116,2257,1751,759,
81,534,1641,610,3355,
954,493,668,409,1065,230,
427,399,29,328,1215,531,
553,321,883,350,476,917,
1626,1458,187,252,688,1134,
540,651,342,606,172,422,
252,102,470,1397,1688,
12385,1498,1284,244,1455,533,
179,759,6851,999,1263,208,
447,423,95,164,477,69,
364,104,2379,46,222,1513,
860,31
];
const net = inserted.map((v, i) => v - deleted[i]);
// cumulative lines of code
const cumulative = [];
net.reduce((sum, v, i) => { cumulative[i] = sum + v; return cumulative[i]; }, 0);
new Chart(document.getElementById('chart'), {
type: 'bar',
data: {
labels,
datasets: [
{
label: 'Lines Added',
data: inserted,
backgroundColor: 'rgba(166,227,161,0.75)',
borderColor: 'rgba(166,227,161,1)',
borderWidth: 1,
yAxisID: 'y',
order: 3,
},
{
label: 'Lines Removed',
data: deleted,
backgroundColor: 'rgba(243,139,168,0.75)',
borderColor: 'rgba(243,139,168,1)',
borderWidth: 1,
yAxisID: 'y',
order: 3,
},
{
label: 'Net Change',
data: net,
type: 'line',
borderColor: 'rgba(203,166,247,0.9)',
backgroundColor: 'transparent',
borderWidth: 2,
pointRadius: 3,
pointBackgroundColor: 'rgba(203,166,247,1)',
tension: 0.3,
yAxisID: 'y',
order: 2,
},
{
label: 'Cumulative LOC',
data: cumulative,
type: 'line',
borderColor: 'rgba(137,180,250,0.9)',
backgroundColor: 'rgba(137,180,250,0.08)',
borderWidth: 2,
pointRadius: 2,
pointBackgroundColor: 'rgba(137,180,250,1)',
tension: 0.3,
fill: true,
yAxisID: 'y2',
order: 1,
}
]
},
options: {
responsive: true,
interaction: { mode: 'index', intersect: false },
plugins: {
legend: {
labels: { color: '#cdd6f4', font: { family: 'monospace' } }
},
tooltip: {
callbacks: {
label: ctx => ` ${ctx.dataset.label}: ${ctx.parsed.y.toLocaleString()}`
}
}
},
scales: {
x: {
ticks: { color: '#6c7086', font: { family: 'monospace', size: 10 },
maxRotation: 60, minRotation: 40 },
grid: { color: 'rgba(108,112,134,0.2)' }
},
y: {
position: 'left',
title: { display: true, text: 'Lines / Day', color: '#a6e3a1',
font: { family: 'monospace' } },
ticks: { color: '#6c7086', font: { family: 'monospace' },
callback: v => v.toLocaleString() },
grid: { color: 'rgba(108,112,134,0.2)' }
},
y2: {
position: 'right',
title: { display: true, text: 'Cumulative LOC', color: '#89b4fa',
font: { family: 'monospace' } },
ticks: { color: '#89b4fa', font: { family: 'monospace' },
callback: v => (v/1000).toFixed(0) + 'k' },
grid: { drawOnChartArea: false }
}
}
}
});
</script>
</body>
</html>