commit 9a0317f1dc277519829e9372b542aa2adac6e944
parent db5f81122fc9868c4210d492e7c225e36d37ae3b
Author: Daniel <23189912+danyisill@users.noreply.github.com>
Date: Wed, 10 Aug 2022 15:52:43 +0300
Update index.html
Diffstat:
1 file changed, 29 insertions(+), 3 deletions(-)
diff --git a/web/index.html b/web/index.html
@@ -76,9 +76,8 @@
src="https://discordemoji.com/assets/emoji/BlobUWU.png" />
</h1>
<p>Active in <span class="pink">{{GUILD_COUNT}}</span> Guilds!</p>
- <p>
- Maybe <span class="pink">Danny</span> will put
- cool usage graphs here one day...
+ <p id="chart">
+ Aggregate command usage chart:
</p>
</div>
</div>
@@ -116,5 +115,32 @@
<a class="gitlink" target="_blank" href="https://github.com/Demonstrandum/Simp-O-Matic">
<img src="https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/github.svg" height=22 alt="GitHub" />
</a>
+ <script src="https://cdn.jsdelivr.net/npm/d3@7"></script>
+ <script src="https://cdn.jsdelivr.net/npm/@observablehq/plot@0.5"></script>
+ <script>
+ const mergeWithSum = (a, b) =>
+ [...Object.keys(a), ...Object.keys(b)].reduce((combined, key) => {
+ combined[key] = (a[key] ?? 0) + (b[key] ?? 0);
+ return combined;
+ }, {});
+ async function load() {
+ let url = 'https://simp.knutsen.co/config.json'
+ let config = await (await fetch(url)).json();
+ let statsAgg = Object.entries(Object.entries(config.guilds).map(([k, v]) => v.stats.commands).reduce((acc, a) => mergeWithSum(acc, a), {})).map(([k, v]) => {
+ return {
+ cmd: k,
+ freq: v
+ }
+ })
+ console.log(statsAgg)
+ document.getElementById('chart').append(Plot.plot({
+ marks: [
+ Plot.barY(statsAgg, {x: "cmd", y: "freq", fill: "steelblue", sort: {x: "y", reverse: true}}),
+ Plot.ruleY([0])
+ ]
+ }))
+ }
+ load();
+ </script>
</body>
</html>