section zoneplaces sur infos générales

This commit is contained in:
Tykayn 2025-11-26 00:57:57 +01:00 committed by tykayn
parent 5186eb17bb
commit 738f3eeb9d
4 changed files with 455 additions and 5 deletions

View file

@ -210,6 +210,36 @@
<div id="graphiques" class="section-anchor">
<h2>Graphiques</h2>
{# Graphique d'activité récente #}
{% if chart_data is defined and chart_data.dates|length > 0 %}
<div class="card mb-4">
<div class="card-header">
<h5><i class="bi bi-graph-up"></i> Activité récente (créations et suppressions)</h5>
</div>
<div class="card-body">
<canvas id="recentActivityChart" style="max-height: 300px;"></canvas>
</div>
</div>
{% endif %}
<div class="card-footer d-flex justify-content-between align-items-center flex-wrap gap-2">
<div>
<a href="{{ path('app_public_zone_places_history', {'insee_code': stats.zone}) }}" class="btn btn-sm btn-outline-primary">
<i class="bi bi-clock-history"></i> Historique des objets
</a>
</div>
<div>
<a href="{{ path('app_public_atom_city_creations', {'insee_code': stats.zone}) }}" class="btn btn-sm btn-outline-success" target="_blank" title="Flux Atom des créations">
<i class="bi bi-rss"></i> <i class="bi bi-plus-circle"></i> Créations
</a>
<a href="{{ path('app_public_atom_city_deletions', {'insee_code': stats.zone}) }}" class="btn btn-sm btn-outline-danger" target="_blank" title="Flux Atom des suppressions">
<i class="bi bi-rss"></i> <i class="bi bi-dash-circle"></i> Suppressions
</a>
</div>
</div>
<div class="row">
<div class="col-md-6 col-12">
<canvas id="repartition_tags" width="600" height="400"
@ -244,6 +274,9 @@
<a href="https://www.openstreetmap.org/copyright">Données OpenStreetMap</a>
</div>
</div>
</div>
{% if stats.population %}
<div class="row mb-3">
@ -1417,4 +1450,127 @@
});
});
</script>
<script>
// Graphique d'activité récente
{% if chart_data is defined and chart_data.dates|length > 0 %}
{% set hasCompletionData = false %}
{% for comp in chart_data.completion %}
{% if comp is not null %}
{% set hasCompletionData = true %}
{% endif %}
{% endfor %}
document.addEventListener('DOMContentLoaded', function() {
const chartCanvas = document.getElementById('recentActivityChart');
if (chartCanvas) {
const chartData = {
labels: {{ chart_data.dates|json_encode|raw }},
datasets: [
{
label: 'Suppressions',
data: {{ chart_data.deletions|json_encode|raw }},
borderColor: 'rgb(220, 53, 69)',
backgroundColor: 'rgba(220, 53, 69, 0.1)',
tension: 0.4,
fill: true
},
{
label: 'Créations',
data: {{ chart_data.creations|json_encode|raw }},
borderColor: 'rgb(25, 135, 84)',
backgroundColor: 'rgba(25, 135, 84, 0.1)',
tension: 0.4,
fill: true
}
{% if hasCompletionData %}
,{
label: 'Complétion générale (%)',
data: {{ chart_data.completion|json_encode|raw }},
borderColor: 'rgb(13, 110, 253)',
backgroundColor: 'rgba(13, 110, 253, 0.1)',
tension: 0.4,
fill: false,
yAxisID: 'y1',
borderDash: [5, 5]
}
{% endif %}
]
};
new Chart(chartCanvas, {
type: 'line',
data: chartData,
options: {
responsive: true,
maintainAspectRatio: true,
interaction: {
mode: 'index',
intersect: false,
},
plugins: {
legend: {
display: true,
position: 'top',
},
tooltip: {
callbacks: {
label: function(context) {
let label = context.dataset.label || '';
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
if (context.dataset.label === 'Complétion générale (%)') {
label += context.parsed.y.toFixed(1) + '%';
} else {
label += context.parsed.y;
}
} else {
label += 'N/A';
}
return label;
}
}
}
},
scales: {
x: {
display: true,
title: {
display: true,
text: 'Date'
}
},
y: {
type: 'linear',
display: true,
position: 'left',
title: {
display: true,
text: 'Nombre d\'objets'
},
beginAtZero: true
}
{% if hasCompletionData %}
,y1: {
type: 'linear',
display: true,
position: 'right',
title: {
display: true,
text: 'Complétion (%)'
},
beginAtZero: true,
max: 100,
grid: {
drawOnChartArea: false,
},
}
{% endif %}
}
}
});
}
});
{% endif %}
</script>
{% endblock %}