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

56 lines
2.1 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 os, count(os)+0 as `nb` FROM stats group by os order by `nb` asc;";
if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .=monDebug(2, ['reqSelect' => $reqSelect],'graphOS');}
$resConn=$idPdo->query($reqSelect);
$l=-1;
while ($tbP=$resConn->fetch(PDO::FETCH_ASSOC)) {
$l++;
$data[$l]=$tbP['nb'];
$lib[$l]=$tbP['os'];
// echo '$data[' .$l. ']=' .$data[$l];
}
$largeur = 470;
$hauteur = 400;
if(count($lib)> 200) $hauteur = 20 * 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(110,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');
$graph->xaxis->SetTickLabels($lib);
$graph->xaxis->SetTextLabelInterval(1);
$graph->title->SET("Histogramme des pages visit&#233;es par systeme d'exploitation");
$graph->stroke();
?>