Commit 8721cfd5 authored by JonathanMM's avatar JonathanMM

Affichage sur le graphique des stations détectées

parent b79b4f68
......@@ -502,12 +502,14 @@ function getDataConsoInstantane()
$allConso = $requete->fetchAll();
$dates = [];
$nbStationsData = [];
$nbStationsDetecteData = [];
foreach($allConso as $i => $c)
{
if($c['nbStation'] > 0)
{
$dates[] = (new DateTime($c['date']))->format("d/m H\hi");
$nbStationsData[] = $c['nbStation'];
$nbStationsDetecteData[] = $c['nbStationDetecte'];
}
}
......@@ -515,9 +517,14 @@ function getDataConsoInstantane()
'labels' => $dates,
'datasets' => array(
array(
'label' => 'Nombre de stations',
'label' => 'Stations annoncées',
'backgroundColor' => 'rgba(173,0,130,0.5)',
'data' => $nbStationsData
),
array(
'label' => 'Stations détectées',
'backgroundColor' => 'rgba(208,74,5,0.5)',
'data' => $nbStationsDetecteData
)
)
);
......@@ -629,19 +636,26 @@ function getDataConsoResume($filtre, $periode)
$datesResume = [];
$nbStationsData = [];
$nbStationsDetecteData = [];
foreach($resumeStatusStation as $statut)
{
$datesResume[] = (new DateTime($statut['date']))->format("d/m H\hi");
$nbStationsData[] = $statut['nbStation'];
$nbStationsDetecteData[] = $statut['nbStationDetecte'];
}
return array(
'labels' => $datesResume,
'datasets' => array(
array(
'label' => 'Nombre de stations',
'label' => 'Stations annoncées',
'backgroundColor' => 'rgba(173,0,130,0.5)',
'data' => $nbStationsData
),
array(
'label' => 'Stations détectées',
'backgroundColor' => 'rgba(208,74,5,0.5)',
'data' => $nbStationsDetecteData
)
)
);
......
......@@ -66,7 +66,7 @@ function displayGraph(actionUrl, choixType)
});
}
function getDisplayData(displayBike, displayInstantanne)
function getDisplayData(displayBike, displayInstantanne, displayStations)
{
var dataDisplay = graphData;
var displayDetails = $("#displayDetails").prop('checked');
......@@ -74,6 +74,8 @@ function getDisplayData(displayBike, displayInstantanne)
displayInstantanne = $("#dureeGraphiqueSelect").val() == 'instantanee';
if(displayBike == undefined)
displayBike = $("#typeGraphiqueSelect").val() == 'Bike';
if(displayStations == undefined)
displayStations = false;
if(displayInstantanne || !displayDetails)
{
if(displayBike) //Vélos
......@@ -92,6 +94,20 @@ function getDisplayData(displayBike, displayInstantanne)
delete dataDisplay.data.datasets[1].borderColor;
dataDisplay.options.scales.yAxes[0].stacked = true;
}
else if(displayStations) // Stations
{
dataDisplay.data.datasets = [graphDataSets[0], graphDataSets[1]];
//On ajuste les couleurs
dataDisplay.data.datasets[0].backgroundColor = 'rgba(173,0,130,0.5)';
dataDisplay.data.datasets[0].fill = true;
delete dataDisplay.data.datasets[0].borderColor;
dataDisplay.data.datasets[1].backgroundColor = 'rgba(208,74,5,0.5)';
dataDisplay.data.datasets[1].fill = true;
delete dataDisplay.data.datasets[1].borderColor;
dataDisplay.options.scales.yAxes[0].stacked = false;
dataDisplay.options.scales.yAxes[0].ticks = {min: 0};
}
else //Bornes
{
dataDisplay.data.datasets = [graphDataSets[0]];
......@@ -139,11 +155,13 @@ function updateGraph(data, choixType)
var idChart = "#chartBikes";
var isBike;
var isInstantanne;
var isStation;
if(choixType == 'Conso')
{
idChart = '#chartNbStations';
isBike = false;
isInstantanne = $("#dureeGraphiqueSelect").val() == 'instantanee';
isStation = true;
} else if(choixType == 'ConsoBike')
{
isBike = true;
......@@ -161,7 +179,7 @@ function updateGraph(data, choixType)
graphDataSets = data.data.datasets;
}
graphInstance[choixType] = new Chart(chartBikes, getDisplayData(isBike, isInstantanne));
graphInstance[choixType] = new Chart(chartBikes, getDisplayData(isBike, isInstantanne, isStation));
}
function displayDetails()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment