osm-labo/templates/public/followup_graph.html.twig

153 lines
No EOL
6.1 KiB
Twig

{% extends 'base.html.twig' %}
{% block title %}Graphe thématique : {{ theme_label }} - {{ stats.name }}{% endblock %}
{% block stylesheets %}
{{ parent() }}
<link href='{{ asset('js/maplibre/maplibre-gl.css') }}' rel='stylesheet'/>
{% endblock %}
{% block body %}
<div class="container mt-4">
<div class="row">
<div class="col-12">
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h1><i class="bi {{ icons[theme]|default('bi-question-circle') }}"></i> {{ theme_label }}</h1>
<p class="text-muted mb-0">{{ stats.name }} ({{ stats.zone }})</p>
</div>
<div>
<a href="{{ path('app_admin_stats', {'insee_code': stats.zone}) }}" class="btn btn-info me-2">
<i class="bi bi-bar-chart"></i> Voir la page de la ville
</a>
<a href="{{ path('app_public_index') }}" class="btn btn-secondary">
<i class="bi bi-arrow-left"></i> Retour à l'accueil
</a>
</div>
</div>
<div class="card">
<div class="card-header">
<h3><i class="bi bi-graph-up"></i> Évolution du {{ theme_label|lower }}</h3>
<p class="mb-0">Suivi de la progression du nombre d'objets et du taux de complétion</p>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<h5>Nombre d'objets</h5>
<canvas id="countChart" height="300"></canvas>
</div>
<div class="col-md-6">
<h5>Taux de complétion (%)</h5>
<canvas id="completionChart" height="300"></canvas>
</div>
</div>
<div class="mt-4">
<div class="alert alert-info">
<i class="bi bi-info-circle"></i>
<strong>Informations :</strong> Ces graphiques montrent l'évolution du {{ theme_label|lower }} dans {{ stats.name }} au fil du temps.
Le taux de complétion indique le pourcentage d'objets correctement renseignés.
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns@3.0.0"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const countData = {{ count_data|raw }};
const completionData = {{ completion_data|raw }};
// Graphique du nombre d'objets
const countCtx = document.getElementById('countChart').getContext('2d');
new Chart(countCtx, {
type: 'line',
data: {
labels: countData.map(d => d.date),
datasets: [{
label: 'Nombre d\'objets',
data: countData.map(d => d.value),
borderColor: 'rgb(54, 162, 235)',
backgroundColor: 'rgba(54, 162, 235, 0.1)',
tension: 0.3,
fill: false
}]
},
options: {
responsive: true,
plugins: {
title: {
display: true,
text: 'Évolution du nombre d\'objets'
}
},
scales: {
y: {
beginAtZero: true,
title: {
display: true,
text: 'Nombre d\'objets'
}
},
x: {
title: {
display: true,
text: 'Date'
}
}
}
}
});
// Graphique du taux de complétion
const completionCtx = document.getElementById('completionChart').getContext('2d');
new Chart(completionCtx, {
type: 'line',
data: {
labels: completionData.map(d => d.date),
datasets: [{
label: 'Taux de complétion (%)',
data: completionData.map(d => d.value),
borderColor: 'rgb(75, 192, 192)',
backgroundColor: 'rgba(75, 192, 192, 0.1)',
tension: 0.3,
fill: false
}]
},
options: {
responsive: true,
plugins: {
title: {
display: true,
text: 'Évolution du taux de complétion'
}
},
scales: {
y: {
beginAtZero: true,
max: 100,
title: {
display: true,
text: 'Taux de complétion (%)'
}
},
x: {
title: {
display: true,
text: 'Date'
}
}
}
}
});
});
</script>
{% endblock %}