Skip to content

Commit e69e638

Browse files
committed
Add commit history bar graph: fix ruffle-rs#89
1 parent c006a87 commit e69e638

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed

_includes/footer.html

+91
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,81 @@
22
<script src="https://code.jquery.com/jquery-3.5.1.min.js"
33
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
44
<script type="text/javascript" src="{{ "/assets/bootstrap/js/bootstrap.min.js" | relative_url }}"></script>
5+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.min.js"></script>
56
<script type="text/javascript">
7+
function createChart(labels, dat) {
8+
const ctx = $("#weeklyCommits");
9+
const data = {
10+
labels: labels,
11+
datasets: [{
12+
data: dat,
13+
backgroundColor: "#FFAD33",
14+
hoverBackgroundColor: "#FFAD33"
15+
}]
16+
};
17+
18+
const options = {
19+
scales: {
20+
y: {
21+
ticks: {
22+
beginAtZero: true,
23+
color: "#FFAD33"
24+
},
25+
grid: {
26+
drawBorder: false,
27+
display: false
28+
}
29+
},
30+
x: {
31+
ticks: {
32+
maxTicksLimit: 18,
33+
color: "#FFAD33"
34+
},
35+
grid: {
36+
drawBorder: false,
37+
display: false
38+
}
39+
}
40+
},
41+
plugins: {
42+
title: {
43+
display: true,
44+
position: "top",
45+
text: "Weekly Contributions",
46+
color: "#FFAD33",
47+
font: {
48+
size: 18,
49+
}
50+
},
51+
legend: {
52+
display: false
53+
},
54+
tooltip: {
55+
backgroundColor: "#FFAD33",
56+
borderWidth: 1,
57+
borderColor: "#1a2743",
58+
titleColor: "#37528C",
59+
titleMarginBottom: 0,
60+
callbacks: {
61+
title: (t) => {
62+
return t[0].formattedValue + " commits the week of " + new Date(t[0].label).toLocaleString(undefined, {
63+
month: "short",
64+
day: "numeric"
65+
});
66+
},
67+
label: () => ""
68+
}
69+
}
70+
}
71+
};
72+
73+
const chart = new Chart(ctx, {
74+
type: "bar",
75+
data: data,
76+
options: options
77+
});
78+
}
79+
680
$(document).ready(function () {
781
var $nav = $('.navbar');
882
var $headerarrow = $('.header-down-arrow');
@@ -23,6 +97,23 @@
2397
}
2498
});
2599
});
100+
const labels = [];
101+
const dat = [];
102+
fetch("https://api.github.com/repos/ruffle-rs/ruffle/stats/commit_activity")
103+
.then(response => response.json())
104+
.then(data => {
105+
Object.values(data).forEach(val => {
106+
if (val.total && val.week) {
107+
dat.push(val.total);
108+
labels.push(
109+
new Date(val.week * 1000).toLocaleDateString(
110+
undefined, {timeZone: "UTC"}
111+
)
112+
);
113+
}
114+
});
115+
createChart(labels, dat);
116+
});
26117
});
27118
</script>
28119
{%- endif -%}

assets/title.scss

+7-1
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,10 @@ a.store-badge {
357357
@keyframes progressBar {
358358
0% { width: 0; }
359359
100% { width: 100%; }
360-
}
360+
}
361+
362+
#weeklyCommits {
363+
width: 100%;
364+
max-width: 1250px;
365+
max-height: 300px;
366+
}

index.html

+5
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ <h5>ActionScript 3 API <code>5%</code></h5>
339339
</p>
340340
</div>
341341
</div>
342+
<div class="row">
343+
<div class="col-base col-lg d-flex justify-content-center">
344+
<canvas id="weeklyCommits"></canvas>
345+
</div>
346+
</div>
342347
</section>
343348
<section class="section content">
344349
<h2 id="get-involved">Get involved</h2>

0 commit comments

Comments
 (0)