up pages rues et évolutions dans le temps

This commit is contained in:
Tykayn 2025-07-12 12:53:06 +02:00 committed by tykayn
parent 7355600e6b
commit c8e3cf2ada
10 changed files with 329 additions and 14 deletions

View file

@ -20,6 +20,54 @@
</a>
</div>
<p>Historique des objets suivis (nombre et complétion).</p>
<div id="objets_modified_lately">
{% set has_change = false %}
<table class="table table-bordered table-sm align-middle table-sortable" id="latestDiffsTable">
<thead>
<tr>
<th>Thème</th>
<th>Évolution du nombre</th>
<th>Évolution de la complétion</th>
</tr>
</thead>
<tbody>
{% for type, diff in latest_diffs %}
{% if diff.count_diff is not null and diff.count_diff != 0 %}
{% set has_change = true %}
<tr>
<td>
<a href="{{ path('admin_followup_theme_graph', {'insee_code': stats.zone, 'theme': type}) }}" class="fw-bold text-decoration-none">
<i class="bi {{ followup_icons[type]|default('bi-question-circle') }}"></i> {{ diff.label }}
</a>
</td>
<td>
{% if diff.count_diff > 0 %}
<i class="bi bi-arrow-up text-success"></i>
{% else %}
<i class="bi bi-arrow-down text-danger"></i>
{% endif %}
{{ diff.count_diff > 0 ? '+' ~ diff.count_diff : diff.count_diff }} objets
</td>
<td>
{% if diff.completion_diff > 0 %}
<i class="bi bi-arrow-up text-success"></i>
{% elseif diff.completion_diff < 0 %}
<i class="bi bi-arrow-down text-danger"></i>
{% else %}
<i class="bi bi-arrow-right text-secondary"></i>
{% endif %}
{{ diff.completion_diff > 0 ? '+' ~ diff.completion_diff : diff.completion_diff }}%
</td>
</tr>
{% endif %}
{% endfor %}
{% if not has_change %}
<tr><td colspan="3" class="text-muted">Aucun changement significatif cette semaine.</td></tr>
{% endif %}
</tbody>
</table>
</div>
{% for type, label in followup_labels %}
<h2 id="title-{{ type }}"><i class="bi {{ followup_icons[type]|default('bi-question-circle') }} fs-2"></i> {{ label }}</h2>
<canvas id="{{ type }}Chart" width="600" height="400"></canvas>
@ -41,6 +89,8 @@
'all_types': [type]
} %}
{% endfor %}
<h2 class="mt-4">Comparaison de la complétion par thème</h2>
<canvas id="multiCompletionChart" width="900" height="400"></canvas>
<h2 class="mt-4">Données brutes</h2>
<table class="table table-bordered table-striped">
<thead>
@ -71,10 +121,11 @@
<script src="/js/chartjs/chart.umd.js"></script>
<script src="/js/chartjs/chartjs-adapter-date-fns.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2"></script>
<script src="/assets/js/table-sortable.js"></script>
<script>
const series = {{ series|json_encode|raw }};
const followupIcons = {{ followup_icons|json_encode|raw }};
const typeLabels = Object.assign({}, {{ followup_labels|json_encode|raw }});
const typeLabels = Object.assign({}, {{ followup_labels|json_encode|raw }});
document.addEventListener('DOMContentLoaded', function() {
Object.keys(typeLabels).forEach(function(baseType) {
const countData = (series[baseType + '_count'] || []).map(pt => ({ x: pt.date, y: pt.value }));
@ -169,6 +220,7 @@
canvas.parentNode.insertBefore(dateDiv, canvas.nextSibling);
}
});
});
</script>
{% endblock %}