ngxstat/templates/report.html

42 lines
1.2 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{ interval.title() }} Report</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body class="section">
<div class="container">
<h1 class="title">{{ interval.title() }} Report</h1>
<canvas id="chart"></canvas>
</div>
<script>
fetch('{{ json_path }}')
.then(r => r.json())
.then(data => {
const labels = data.map(x => x.bucket);
const hits = data.map(x => x.hits);
new Chart(document.getElementById('chart'), {
type: '{{ 'bar' if interval == 'hourly' else 'line' }}',
data: {
labels: labels,
datasets: [{
label: 'Hits',
data: hits,
backgroundColor: 'rgba(54, 162, 235, 0.5)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1,
fill: true,
}]
},
options: {
scales: {
y: { beginAtZero: true }
}
}
});
});
</script>
</body>
</html>