up commande labourage queue
This commit is contained in:
parent
ca0ec580f5
commit
1345cc903b
9 changed files with 532 additions and 441 deletions
|
@ -136,8 +136,10 @@
|
|||
'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">Évolution du taux de complétion (CTC - Complète tes commerces)</h2>
|
||||
<canvas id="ctcCompletionChart" width="900" height="400"></canvas>
|
||||
|
||||
<h2 class="mt-4">Données brutes</h2>
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
|
@ -172,7 +174,8 @@
|
|||
<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 }});
|
||||
const ctcCompletionSeries = {% if ctc_completion_series is defined %}{{ ctc_completion_series|json_encode|raw }} {% endif %} | [];
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
Object.keys(typeLabels).forEach(function(baseType) {
|
||||
const countData = (series[baseType + '_count'] || []).map(pt => ({ x: pt.date, y: pt.value }));
|
||||
|
@ -268,6 +271,53 @@
|
|||
}
|
||||
});
|
||||
|
||||
// --- Graphique séparé pour les données CTC ---
|
||||
if (Object.keys(ctcCompletionSeries).length > 0) {
|
||||
const ctcDatasets = Object.keys(ctcCompletionSeries).map(function(type) {
|
||||
return {
|
||||
label: typeLabels[type.replace('_count','')] || type,
|
||||
data: ctcCompletionSeries[type].map(pt => ({ x: pt.date, y: pt.value })),
|
||||
borderColor: 'orange',
|
||||
backgroundColor: 'rgba(255,165,0,0.1)',
|
||||
fill: false,
|
||||
borderDash: [5,3],
|
||||
datalabels: { display: false }
|
||||
};
|
||||
});
|
||||
const ctcCanvas = document.getElementById('ctcCompletionChart');
|
||||
if (ctcCanvas) {
|
||||
new Chart(ctcCanvas, {
|
||||
type: 'line',
|
||||
data: { datasets: ctcDatasets },
|
||||
options: {
|
||||
parsing: true,
|
||||
responsive: true,
|
||||
plugins: {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Évolution des complétions (CTC)'
|
||||
},
|
||||
datalabels: { display: false },
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
title: function(context) {
|
||||
return context[0].parsed.x ? new Date(context[0].parsed.x).toLocaleString() : '';
|
||||
},
|
||||
label: function(context) {
|
||||
return context.dataset.label + ': ' + context.parsed.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
x: { type: 'time', time: { unit: 'day' }, title: { display: true, text: 'Date' } },
|
||||
y: { beginAtZero: true, title: { display: true, text: 'Nombre' } }
|
||||
}
|
||||
},
|
||||
plugins: [ChartDataLabels]
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -1166,4 +1166,37 @@ if(dc ){
|
|||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const ctcCompletionSeries = {{ ctc_completion_series|json_encode|raw }};
|
||||
|
||||
console.log('ctcCompletionSeries',ctcCompletionSeries)
|
||||
// Exemple d'intégration dans un graphique Chart.js :
|
||||
// Pour chaque type, ajouter une série CTC si elle existe
|
||||
Object.keys(ctcCompletionSeries).forEach(function(type) {
|
||||
const data = ctcCompletionSeries[type].map(pt => ({ x: pt.date, y: pt.value }));
|
||||
// Ajoute la série au graphique correspondant (ex: name_count, hours_count...)
|
||||
// À adapter selon l'ID du canvas et la structure du graphique
|
||||
const canvasId = type.replace('_count','') + 'Chart';
|
||||
const canvas = document.getElementById(canvasId);
|
||||
if (!canvas) return;
|
||||
// On suppose que le graphique existe déjà, on ajoute la série CTC
|
||||
if (canvas.chart) {
|
||||
canvas.chart.data.datasets.push({
|
||||
label: 'CTC (Complète tes commerces)',
|
||||
data: data,
|
||||
borderColor: 'orange',
|
||||
backgroundColor: 'rgba(255,165,0,0.1)',
|
||||
fill: false,
|
||||
yAxisID: 'y',
|
||||
borderDash: [5,3],
|
||||
datalabels: {
|
||||
display: false
|
||||
}
|
||||
});
|
||||
canvas.chart.update();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue