50 lines
1.4 KiB
HTML
50 lines
1.4 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>
|
|
{% for report in reports %}
|
|
<div class="box">
|
|
<h2 class="subtitle">{{ report.label }}</h2>
|
|
<canvas id="chart-{{ report.name }}"></canvas>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
<script>
|
|
const reports = {{ reports | tojson }};
|
|
reports.forEach(rep => {
|
|
fetch(rep.json)
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
const labels = data.map(x => x.bucket);
|
|
const values = data.map(x => x.value);
|
|
new Chart(document.getElementById('chart-' + rep.name), {
|
|
type: rep.chart,
|
|
data: {
|
|
labels: labels,
|
|
datasets: [{
|
|
label: rep.label,
|
|
data: values,
|
|
backgroundColor: 'rgba(54, 162, 235, 0.5)',
|
|
borderColor: 'rgba(54, 162, 235, 1)',
|
|
borderWidth: 1,
|
|
fill: rep.chart !== 'bar',
|
|
}]
|
|
},
|
|
options: {
|
|
scales: {
|
|
y: { beginAtZero: true }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|