Ajout des chiffres pour l'agglo entière

This commit is contained in:
Fedaya 2025-03-04 20:55:44 +01:00
parent c2c9ff2c50
commit 269266de77
2 changed files with 24 additions and 6 deletions

View File

@ -84,16 +84,34 @@ while($line = $data->fetchArray()) {
$dataset_angers[] = array('x' => date_format(date_create($line['date']), 'Y/m/d H:i'), 'y'=>$line['nombre']);
}
$json_angers = json_encode($dataset_angers);
$data = $base->query("SELECT date, SUM(nombre) as nombre FROM chiffres GROUP BY date");
$dataset_tout = [];
while($line = $data->fetchArray()) {
$dataset_tout[] = array('x' => date_format(date_create($line['date']), 'Y/m/d H:i'), 'y'=>$line['nombre']);
}
$json_tout = json_encode($dataset_tout);
?>
<script type="text/javascript">
const data_angers = <?=$json_angers?>;
const data_tout = <?=$json_tout?>;
(async function() {
const myChart = new Chart(document.getElementById('graphe_angers'), { type:'line', data: {datasets: [{
type: 'line',
label:"Angers",
data: data_angers,
tension: 0.1
}]}});
const myChart = new Chart(document.getElementById('graphe_angers'), {
type:'line',
data: {
datasets: [{
type: 'line',
label:"Angers",
data: data_angers,
tension: 0.1
},
{
type: 'line',
label: "Agglomération entière",
data: data_tout,
tension: 0.1
}]
}
});
})();
</script>
<hr/>

Binary file not shown.