93 lines
3.2 KiB
PHP
Executable File
93 lines
3.2 KiB
PHP
Executable File
<?php
|
|
$nomFicAppelant = basename(__FILE__);
|
|
require_once("jpgraph/src/jpgraph.php");
|
|
require_once("jpgraph/src/jpgraph_bar.php");
|
|
|
|
if(file_exists("../../_include/dataBaseConnect.php")) {$includePathConf="../../_conf";include ("../../_include/dataBaseConnect.php");}
|
|
if (isset($debug[2]) && $debug[2] == '1' ) {$includePathConf="../../../_conf"; if(file_exists("../../../_include/dataBaseConnect.php")) include ("../../../_include/dataBaseConnect.php");}
|
|
|
|
// -----------------------------------------------------
|
|
// Mode Test
|
|
// -----------------------------------------------------
|
|
$year="Toutes";
|
|
|
|
if (isset($_SESSION['modeTest'])) $modeTest=$_SESSION['modeTest']; else $modeTest=1;
|
|
if ($modeTest==2) {
|
|
// prendre la BDD prod
|
|
include ($includePathConf. "/prod.dbConnect.php");
|
|
// pour affichage environnement
|
|
$bdd=$bddProd;
|
|
$idPdo=$idPdoProd;
|
|
}
|
|
|
|
if (isset($_SESSION['year'])) $year=$_SESSION['year'];
|
|
if (isset($_GET['year'])) $year=$_GET['year'];
|
|
|
|
// -----------------------------------------------------
|
|
// Init value
|
|
// -----------------------------------------------------
|
|
$lib[0]="Paris";
|
|
$data[0]="0";
|
|
|
|
if( $year=="Toutes" )
|
|
{ $reqSelect="SELECT ville, count(ville) as `nb`, region, pays FROM `stats` group by region HAVING `nb`>5 order by `nb` desc;"; }
|
|
else
|
|
{ $reqSelect="SELECT ville, count(ville) as `nb`, region, pays FROM `stats` WHERE substr(timestamp,1,4)=" .$year. " group by region HAVING `nb`>5 order by `nb` desc;"; }
|
|
if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .=monDebug(2, ['reqSelect' => $reqSelect],'graphPays');}
|
|
|
|
$resConn=$idPdo->query($reqSelect);
|
|
$l=-1;
|
|
// ---------------------------------------------------
|
|
// Formattage des nombres
|
|
// ---------------------------------------------------
|
|
function format_number_with_space($aVal) {
|
|
return number_format($aVal, 0, ',', ' '); // Espace comme séparateur de milliers
|
|
}
|
|
// ---------------------------------------------------
|
|
// Recup datas
|
|
// ---------------------------------------------------
|
|
while ($tbP=$resConn->fetch(PDO::FETCH_ASSOC)) {
|
|
$l++;
|
|
$data[$l]=$tbP['nb'];
|
|
$lib[$l]=$tbP['ville'];
|
|
// echo '$data[' .$l. ']=' .$data[$l];
|
|
}
|
|
|
|
$largeur = 500;
|
|
$hauteur = 800;
|
|
if(count($lib)> 60) $hauteur = 18 * count($lib);
|
|
$graph = new Graph($largeur, $hauteur, "auto");
|
|
$graph->setScale("textlin");
|
|
$graph->SetShadow();
|
|
|
|
$barPlot = new BarPlot($data);
|
|
$graph->add($barPlot);
|
|
$barPlot->SetFillgradient('darkgreen','#D5EAFF',GRAD_WIDE_MIDVER);
|
|
$barPlot->value->Show();
|
|
$barPlot->value->SetFormat('%d');
|
|
$barPlot->SetValuePos('center');
|
|
$barPlot->SetValuePos('center');
|
|
$barPlot->SetValuePos('top');
|
|
$barPlot->value->SetColor("darkgreen","darkred");
|
|
|
|
$barPlot->value->SetFormatCallback('format_number_with_space');
|
|
|
|
// gauche-droit-haut-bas
|
|
$graph->Set90AndMargin(130,40,30,30);
|
|
|
|
// Axe des ordonées
|
|
$graph->xaxis->SetPos('SIDE_LEFT');
|
|
$graph->xaxis->SetColor('black','blue');
|
|
$graph->xaxis->SetTickLabels($lib);
|
|
$graph->xaxis->SetTextLabelInterval(1);
|
|
|
|
// Axe des abscisses
|
|
// $graph->yaxis->SetTextLabelInterval(520);
|
|
$graph->yaxis->SetLabelMargin(-12);
|
|
$graph->yaxis->scale->SetGrace(0);
|
|
$graph->yaxis->SetPos('max');
|
|
|
|
$graph->title->SET("Villes avec + de 5 visites / Année : " .$year);
|
|
|
|
$graph->stroke();
|
|
?>
|