bug-chart/template.html

68 lines
1.9 KiB
HTML
Raw Permalink Normal View History

2023-12-21 18:49:15 +00:00
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Open bugs over time</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns/dist/chartjs-adapter-date-fns.bundle.min.js"></script>
2023-12-22 19:56:27 +00:00
<script src="https://cdn.jsdelivr.net/npm/hammerjs@2.0.8"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-zoom/dist/chartjs-plugin-zoom.min.js"></script>
2023-12-21 18:49:15 +00:00
</head>
<body>
<canvas id="bugChart" width="800" height="400"></canvas>
<script>
document.addEventListener('DOMContentLoaded', function () {
const jsonData = [];
var labels = jsonData.map(function(pair) { return pair[0]; });
var data = jsonData.map(function(pair) { return pair[1]; });
var ctx = document.getElementById('bugChart').getContext('2d');
var chart = new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [{
label: 'Open bugs over time',
backgroundColor: 'rgba(0, 123, 255, 0.5)',
borderColor: 'rgba(0, 123, 255, 1)',
borderWidth: 1,
data: data
}]
},
2023-12-22 19:56:27 +00:00
2023-12-21 18:49:15 +00:00
options: {
2023-12-22 19:56:27 +00:00
plugins: {
zoom: {
pan: {
enabled: true,
},
zoom: {
wheel: { enabled: true },
pinch: { enabled: true },
mode: 'xy',
}
}
},
2023-12-21 18:49:15 +00:00
scales: {
x: {
type: 'time',
2023-12-21 19:54:13 +00:00
time: {unit: 'month'}
2023-12-21 18:49:15 +00:00
},
y: {
ticks: {
beginAtZero: true
}
}
}
}
});
});
</script>
</body>
</html>