diff --git a/assets/app.js b/assets/app.js index 52a290f..782e2a7 100644 --- a/assets/app.js +++ b/assets/app.js @@ -29,96 +29,6 @@ window.getLabourerUrl = getLabourerUrl; Chart.register(ChartDataLabels); -function initDashboardChart() { - const chartCanvas = document.getElementById('statsBubbleChart'); - if (!chartCanvas) { - return; - } - - if (!chartCanvas.dataset.stats || chartCanvas.dataset.stats.length <= 2) { // <= 2 pour ignorer '[]' - console.log("Les données du graphique sont vides ou absentes, le graphique ne sera pas affiché."); - return; - } - - const statsData = JSON.parse(chartCanvas.dataset.stats); - - if (statsData && statsData.length > 0) { - const bubbleChartData = statsData.map(stat => { - const population = parseInt(stat.population, 10); - const placesCount = parseInt(stat.placesCount, 10); - const ratio = population > 0 ? (placesCount / population) * 1000 : 0; - - return { - x: population, - y: ratio, - r: Math.sqrt(placesCount) * 2, - label: stat.name, - completion: stat.completionPercent || 0 - }; - }); - - new Chart(chartCanvas.getContext('2d'), { - type: 'bubble', - data: { - datasets: [{ - label: 'Villes', - data: bubbleChartData, - backgroundColor: bubbleChartData.map(d => `rgba(255, 99, 132, ${d.completion / 100})`), - borderColor: 'rgba(255, 99, 132, 1)', - }] - }, - options: { - responsive: true, - plugins: { - datalabels: { - anchor: 'center', - align: 'center', - color: '#000', - font: { - weight: 'bold' - }, - formatter: (value, context) => { - return context.dataset.data[context.dataIndex].label; - } - }, - legend: { - display: false - }, - tooltip: { - callbacks: { - label: (context) => { - const d = context.raw; - return [ - `${d.label}`, - `Population: ${d.x.toLocaleString()}`, - `Lieux / 1000 hab: ${d.y.toFixed(2)}`, - `Total lieux: ${Math.round(Math.pow(d.r / 2, 2))}`, - `Complétion: ${d.completion}%` - ]; - } - } - } - }, - scales: { - x: { - type: 'logarithmic', - title: { - display: true, - text: 'Population (échelle log)' - } - }, - y: { - title: { - display: true, - text: 'Commerces pour 1000 habitants' - } - } - } - } - }); - } -} - // Attendre le chargement du DOM document.addEventListener('DOMContentLoaded', () => { console.log('DOMContentLoaded'); @@ -266,8 +176,7 @@ document.addEventListener('DOMContentLoaded', () => { }); } - enableLabourageForm(); - initDashboardChart(); - + enableLabourageForm(); adjustListGroupFontSize('.list-group-item'); }); + diff --git a/src/Controller/PublicController.php b/src/Controller/PublicController.php index cb89a3c..09c8ed3 100644 --- a/src/Controller/PublicController.php +++ b/src/Controller/PublicController.php @@ -183,6 +183,8 @@ class PublicController extends AbstractController 'placesCount' => $stat->getPlacesCount(), 'completionPercent' => $stat->getCompletionPercent(), 'population' => $stat->getPopulation(), + 'zone' => $stat->getZone(), + 'osmDataDateAvg' => $stat->getOsmDataDateAvg() ? $stat->getOsmDataDateAvg()->format('Y-m-d') : null, ]; } } diff --git a/templates/admin/stats.html.twig b/templates/admin/stats.html.twig index f987e83..1a9cd17 100644 --- a/templates/admin/stats.html.twig +++ b/templates/admin/stats.html.twig @@ -632,7 +632,7 @@ function getCompletionColor(completion) { if (completion.percentage < 100) { content += `
+