๐Ÿ“ฆ navidrome / insight-charts

๐Ÿ“„ index.html ยท 53 lines
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<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Navidrome insights</title>
    <meta charset="utf-8" />

    <script src="https://cdn.jsdelivr.net/npm/vega@5.30.0"></script>
    <script src="https://cdn.jsdelivr.net/npm/vega-lite@5.21.0"></script>
    <script src="https://cdn.jsdelivr.net/npm/vega-embed@6.26.0"></script>

    <style media="screen">
      .vega-actions a {
        margin-right: 5px;
      }
    </style>
  </head>
  <body>
    <h1>Navidrome insights</h1>
    <div style="text-align: center; width: 100%">
      <div id="vis1" style="margin: 20px auto; width: 100%"></div>
      <div id="vis2" style="margin: 20px auto; width: 100%"></div>
      <div id="vis3" style="margin: 20px auto; width: 100%"></div>
      <div id="vis4" style="margin: 20px auto; width: 100%"></div>
      <div id="vis5" style="margin: 20px auto; width: 100%"></div>
    </div>

    <script type="module">
      async function loadAndRenderCharts() {
        try {
          const [numIns, osPie, musicFsPie, dataFsPie, playerTypePie] =
            await Promise.all([
              fetch("./charts/numInstance.json").then((r) => r.json()),
              fetch("./charts/osPie.json").then((r) => r.json()),
              fetch("./charts/musicFsPie.json").then((r) => r.json()),
              fetch("./charts/dataFsPie.json").then((r) => r.json()),
              fetch("./charts/playerTypePie.json").then((r) => r.json()),
            ]);

          vegaEmbed("#vis1", numIns);
          vegaEmbed("#vis2", osPie);
          vegaEmbed("#vis3", musicFsPie);
          vegaEmbed("#vis4", dataFsPie);
          vegaEmbed("#vis5", playerTypePie);
        } catch (error) {
          console.error("Error loading chart data:", error);
        }
      }

      loadAndRenderCharts();
    </script>
  </body>
</html>