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

82 lines
2.7 KiB
PHP
Executable File

<?php
$nomFicAppelant = basename(__FILE__);
require_once("jpgraph/src/jpgraph.php");
require_once("jpgraph/src/jpgraph_bar.php");
require_once ("jpgraph/src/jpgraph_line.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 * from compteurpages order by compteur desc;";
if (isset($debug[2]) && $debug[2] == '1') {
$debugMsg .= monDebug(2, ['reqSelect' => $reqSelect, 'bdd' => $bdd, 'modeTest' => $modeTest, '$_SESSION[modeTest]' => $_SESSION['modeTest']], 'graphPages.php');
}
$resConn=$idPdo->query($reqSelect);
$l=0;
while ($tbML=$resConn->fetch(PDO::FETCH_ASSOC)) {
$data[$l]=intval($tbML['compteur']);
$lib[$l]=$tbML['idPage'];
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['$lib[$l]' => $lib[$l], '$data[$l]' => $data[$l] ], '');}
$l++;
}
$largeur = 500;
$hauteur = 500;
$graph = new Graph($largeur, $hauteur, "auto");
// Linear scale. Both X and Y axis
// Logarithmic scale. Both X and Y axis
// Text scale. Only on X axis
// Integer scale. X and Y axis
$graph->setScale("textlin");
$barPlot = new BarPlot($data);
$graph->add($barPlot);
$barPlot->SetWidth(0.7);
$barPlot->SetFillgradient('darkgreen','#D5EAFF',GRAD_WIDE_MIDVER);
$barPlot->value->Show();
$barPlot->value->SetFormat('%d');
$barPlot->SetValuePos('top');
$barPlot->SetYBase(4);
$barPlot->value->SetMargin(150);
$barPlot->value->HideZero();
$barPlot->value->SetColor("darkgreen","darkred");
// $graph->SetBackgroundImage("mer_antilles_fond.jpg",BGIMG_FILLFRAME);
// $graph->img->SetAntiAliasing("white");
$graph->SetShadow();
// gauche-droit-haut-bas
$graph->Set90AndMargin(130,20,30,20);
// Axe des ordonées
$graph->xaxis->SetPos('SIDE_LEFT');
$graph->xaxis->SetLabelMargin(10);
$graph->xaxis->SetColor('black','blue');
// Axe des abscisses
$graph->yaxis->SetTextLabelInterval(2);
$graph->yaxis->SetLabelMargin(-15);
$graph->yaxis->scale->SetGrace(0);
$graph->yaxis->SetPos('max');
$graph->yaxis->SetTextLabelInterval(2);
$graph->xaxis->SetTickLabels($lib);
$graph->title->SET("Nombre de visites par page / 'toute date'");
$graph->stroke();
?>