mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-10-04 17:04:53 +02:00
refacto js, up graph
This commit is contained in:
parent
d66bc5e40c
commit
68680e0569
11 changed files with 840 additions and 48 deletions
44
assets/stats-charts.js
Normal file
44
assets/stats-charts.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
// Affichage du graphique de fréquence des mises à jour par trimestre sur la page stats d'une ville
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
function drawModificationsByQuarterChart() {
|
||||
if (!window.Chart) {
|
||||
setTimeout(drawModificationsByQuarterChart, 50);
|
||||
return;
|
||||
}
|
||||
if (typeof window.modificationsByQuarter === 'undefined') return;
|
||||
const modifData = window.modificationsByQuarter;
|
||||
const modifLabels = Object.keys(modifData);
|
||||
const modifCounts = Object.values(modifData);
|
||||
const modifCanvas = document.getElementById('modificationsByQuarterChart');
|
||||
if (modifCanvas && modifLabels.length > 0) {
|
||||
new window.Chart(modifCanvas.getContext('2d'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: modifLabels,
|
||||
datasets: [{
|
||||
label: 'Nombre de lieux modifiés',
|
||||
data: modifCounts,
|
||||
backgroundColor: 'rgba(54, 162, 235, 0.7)',
|
||||
borderColor: 'rgba(54, 162, 235, 1)',
|
||||
borderWidth: 1
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
plugins: {
|
||||
legend: { display: false },
|
||||
title: { display: true, text: 'Fréquence des mises à jour par trimestre' }
|
||||
},
|
||||
scales: {
|
||||
y: { beginAtZero: true, title: { display: true, text: 'Nombre de lieux' } },
|
||||
x: { title: { display: true, text: 'Trimestre' } }
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (modifCanvas) {
|
||||
modifCanvas.parentNode.innerHTML = '<div class="alert alert-info">Aucune donnée de modification disponible pour cette ville.</div>';
|
||||
}
|
||||
}
|
||||
drawModificationsByQuarterChart();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue