|
2 | 2 | <script src="https://code.jquery.com/jquery-3.5.1.min.js"
|
3 | 3 | integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
|
4 | 4 | <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> |
5 | 6 | <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 | + |
6 | 80 | $(document).ready(function () {
|
7 | 81 | var $nav = $('.navbar');
|
8 | 82 | var $headerarrow = $('.header-down-arrow');
|
|
23 | 97 | }
|
24 | 98 | });
|
25 | 99 | });
|
| 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 | + }); |
26 | 117 | });
|
27 | 118 | </script>
|
28 | 119 | {%- endif -%}
|
|
0 commit comments