-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add daily active users chart to the statistics page
- Loading branch information
Showing
4 changed files
with
118 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const ctx = document.getElementById("dailyChart"); | ||
|
||
Chart.defaults.backgroundColor = "rgba(255, 255, 255, 0.2)"; | ||
Chart.defaults.borderColor = "rgba(255, 255, 255, 0.2)"; | ||
Chart.defaults.color = "#FFF"; | ||
|
||
console.log(daily_data); | ||
let labels = daily_data.map(([label, _]) => label); | ||
let counts = daily_data.map(([_, count]) => count); | ||
new Chart(ctx, { | ||
type: "line", | ||
data: { | ||
labels: labels, | ||
datasets: [ | ||
{ | ||
label: "daily active users", | ||
data: counts, | ||
borderWidth: 1, | ||
}, | ||
], | ||
}, | ||
options: { | ||
scales: { | ||
y: { | ||
beginAtZero: true, | ||
}, | ||
}, | ||
elements: { | ||
point: { | ||
radius: 2, | ||
}, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,74 @@ | ||
<!doctype html> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
|
||
<title>Statistics</title> | ||
<meta property="og:title" content="Statistics" /> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="icon" type="image/png" sizes="32x32" href="/static/logo32.png"> | ||
<link rel="icon" type="image/png" sizes="48x48" href="/static/logo48.png"> | ||
<link rel="icon" type="image/png" sizes="192x192" href="/static/logo192.png"> | ||
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="/static/logo180.png"> | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap" | ||
rel="stylesheet"> | ||
<link href="/static/style.css" rel="stylesheet"> | ||
</head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="icon" type="image/png" sizes="32x32" href="/static/logo32.png" /> | ||
<link rel="icon" type="image/png" sizes="48x48" href="/static/logo48.png" /> | ||
<link | ||
rel="icon" | ||
type="image/png" | ||
sizes="192x192" | ||
href="/static/logo192.png" | ||
/> | ||
<link | ||
rel="apple-touch-icon" | ||
type="image/png" | ||
sizes="180x180" | ||
href="/static/logo180.png" | ||
/> | ||
<link rel="preconnect" href="https://fonts.googleapis.com" /> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap" | ||
rel="stylesheet" | ||
/> | ||
<link href="/static/style.css" rel="stylesheet" /> | ||
</head> | ||
|
||
<body class="h-screen"> | ||
<body class="h-screen"> | ||
<div class="h-full flex flex-col justify-between"> | ||
<main class="container w-full max-w-md mx-auto px-4 text-center"> | ||
<h1 class="text-6xl font-bold pt-12 pb-6 leading-snug"> | ||
Statistics | ||
</h1> | ||
<main class="container w-full max-w-[40rem] mx-auto px-4 text-center"> | ||
<h1 class="text-6xl font-bold pt-12 pb-6 leading-snug">Statistics</h1> | ||
|
||
<div class="text-left"> | ||
<ul> | ||
<li>Daily active users: {{statistic.daily_users}}</li> | ||
<li>Montly active users: {{statistic.monthly_users}}</li> | ||
<li>Total users: {{statistic.total_users}}</li> | ||
</ul> | ||
</div> | ||
<ul> | ||
<li>Daily active users: {{statistic.daily_users}}</li> | ||
<li>Montly active users: {{statistic.monthly_users}}</li> | ||
<li>Total users: {{statistic.total_users}}</li> | ||
</ul> | ||
|
||
</main> | ||
<footer class="bg-neutral-900 border-t-2 border-t-[color:#333] p-4 text-sm text-neutral-400 mt-16"> | ||
<div class="container w-full max-w-lg mx-auto"> | ||
<div class="flex flex-row justify-between"> | ||
<div>Made with ❤️ by <a href="https://github.com/flofriday">flofriday</a></div> | ||
<div> | ||
on <a href="https://github.com/flofriday/better-tiss-calendar">GitHub</a> | ||
</div> | ||
</div> | ||
<div class="pt-8 w-full"> | ||
<canvas id="dailyChart"></canvas> | ||
</div> | ||
</main> | ||
<footer | ||
class="bg-neutral-900 border-t-2 border-t-[color:#333] p-4 text-sm text-neutral-400 mt-16" | ||
> | ||
<div class="container w-full max-w-lg mx-auto"> | ||
<div class="flex flex-row justify-between"> | ||
<div> | ||
Made with ❤️ by | ||
<a href="https://github.com/flofriday">flofriday</a> | ||
</div> | ||
</footer> | ||
<div> | ||
on | ||
<a href="https://github.com/flofriday/better-tiss-calendar" | ||
>GitHub</a | ||
> | ||
</div> | ||
</div> | ||
</div> | ||
</footer> | ||
</div> | ||
</body> | ||
|
||
</html> | ||
<!-- prettier-ignore --> | ||
<script> | ||
let daily_data = {{ chart_data | safe }}; | ||
</script> | ||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | ||
<script src="/static/statistics.js"></script> | ||
</body> | ||
</html> |