mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-10-04 17:04:53 +02:00
ajout de stats sur le budget des villes
This commit is contained in:
parent
1973f85dd4
commit
cd8369d08c
14 changed files with 901 additions and 186 deletions
|
@ -122,9 +122,12 @@ function waitForChartAndDrawBubble() {
|
|||
return [
|
||||
`${d.label}`,
|
||||
`Population: ${d.x.toLocaleString()}`,
|
||||
`Lieux / hab: ${d.y.toFixed(2)}`,
|
||||
`Total lieux: ${Math.round(Math.pow(d.r / 2, 2))}`,
|
||||
`Complétion: ${d.completion}%`
|
||||
`Nombre de lieux: ${d.r.toFixed(2)}`,
|
||||
`Complétion: ${d.y.toFixed(2)}%`,
|
||||
`Fraîcheur moyenne: ${d.freshnessDays ? d.freshnessDays.toLocaleString() + ' jours' : 'N/A'}`,
|
||||
`Budget: ${d.budget ? d.budget.toLocaleString() + ' €' : 'N/A'}`,
|
||||
`Budget/habitant: ${d.budgetParHabitant ? d.budgetParHabitant.toFixed(2) + ' €' : 'N/A'}`,
|
||||
`Budget/lieu: ${d.budgetParLieu ? d.budgetParLieu.toFixed(2) + ' €' : 'N/A'}`
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -173,25 +176,53 @@ function getBubbleData(proportional) {
|
|||
const data = window.statsDataForBubble?.map(stat => {
|
||||
const population = parseInt(stat.population, 10);
|
||||
const placesCount = parseInt(stat.placesCount, 10);
|
||||
// const ratio = population > 0 ? (placesCount / population) * 1000 : 0;
|
||||
const completion = parseInt(stat.completionPercent, 10);
|
||||
// Fraîcheur moyenne : âge moyen en jours (plus récent à droite)
|
||||
let freshnessDays = null;
|
||||
if (stat.osmDataDateAvg) {
|
||||
const now = new Date();
|
||||
const avgDate = new Date(stat.osmDataDateAvg);
|
||||
freshnessDays = Math.round((now - avgDate) / (1000 * 60 * 60 * 24));
|
||||
}
|
||||
// Pour l'axe X, on veut que les plus récents soient à droite (donc X = -freshnessDays)
|
||||
const x = freshnessDays !== null ? -freshnessDays : 0;
|
||||
// Budget
|
||||
const budget = stat.budgetAnnuel ? parseFloat(stat.budgetAnnuel) : null;
|
||||
const budgetParHabitant = (budget && population) ? budget / population : null;
|
||||
const budgetParLieu = (budget && placesCount) ? budget / placesCount : null;
|
||||
return {
|
||||
x: population,
|
||||
x: x,
|
||||
y: completion,
|
||||
r: proportional ? Math.sqrt(placesCount) * 2 : 12,
|
||||
label: stat.name,
|
||||
completion: stat.completionPercent || 0,
|
||||
zone: stat.zone
|
||||
zone: stat.zone,
|
||||
budget,
|
||||
budgetParHabitant,
|
||||
budgetParLieu,
|
||||
population,
|
||||
placesCount,
|
||||
freshnessDays
|
||||
};
|
||||
});
|
||||
// Trier du plus gros au plus petit rayon
|
||||
if(data){
|
||||
|
||||
data.sort((a, b) => b.r - a.r);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
waitForChartAndDrawBubble();
|
||||
|
||||
// Forcer deleteMissing=1 sur le formulaire de labourage
|
||||
const labourerForm = document.getElementById('labourerForm');
|
||||
if (labourerForm) {
|
||||
labourerForm.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
const zipCode = document.getElementById('selectedZipCode').value;
|
||||
if (zipCode) {
|
||||
window.location.href = '/admin/labourer/' + zipCode + '?deleteMissing=1';
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue