alpha_full/admin/stats/graphNav.php
2026-04-06 22:58:51 +02:00

58 lines
2.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
// -----------------------------------------------------
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;
}
$reqSelect="SELECT navigateur, count(navigateur)+0 as `nb` FROM stats group by navigateur order by `nb` desc;";
if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .=monDebug(2, ['reqSelect' => $reqSelect],'graphNav');}
$resConn=$idPdo->query($reqSelect);
$l=-1;
while ($tbP=$resConn->fetch(PDO::FETCH_ASSOC)) {
$l++;
$data[$l]=$tbP['nb'];
$lib[$l]=$tbP['navigateur'];
// echo '$data[' .$l. ']=' .$data[$l];
}
$largeur = 470;
$hauteur = 400;
if(count($lib)> 60) $hauteur = 18 * count($lib);
$graph = new Graph($largeur, $hauteur, "auto");
$graph->setScale("textlin");
$histo = new BarPlot($data);
// $graph->SetBackgroundImage("mer_antilles_fond.jpg",BGIMG_FILLFRAME);
// $graph->img->SetAntiAliasing("white");
$graph->SetShadow();
$graph->add($histo);
$graph->Set90AndMargin(130,40,30,30);
$graph->xaxis->SetPos('SIDE_LEFT');
$graph->yaxis->SetLabelMargin(-12);
$graph->xaxis->SetColor('black','blue');
$graph->yaxis->scale->SetGrace(0);
$graph->yaxis->SetPos('max');
$graph->yaxis->SetTickSide(SIDE_LEFT);
$histo->SetFillgradient('#8080FF','#D5EAFF',GRAD_WIDE_MIDVER);
$histo->value->Show();
$histo->value->SetFormat('%d');
$histo->SetValuePos('center');
$histo->SetFillgradient('#8080FF','#D5EAFF',GRAD_WIDE_MIDVER);
$graph->xaxis->SetTickLabels($lib);
$graph->xaxis->SetTextLabelInterval(1);
$graph->title->SET("Histogramme des pages visit&#233;es par navigateur");
$graph->stroke();
?>