1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| <?php
$host = '';
$user = '';
$pass = '';
$db = '';
include ("jpgraph.php");
include ("jpgraph_bar.php");
@mysql_connect($host,$user,$pass) or die("impossible de se connecter : ". mysql_error());
@mysql_select_db($db) or die("impossible de sélectionner la base : ". mysql_error());
$sql_h = 'SELECT distinct hittime, nb, seqno FROM connect';
$data1y = NULL;
$data1x = NULL;
$Resultat = mysql_query($sql_h);
for ($seqno=0 ; $seqno<mysql_numrows($Resultat) ; $seqno++)
{
$data1y[]=mysql_result($Resultat , $seqno , "nb");
$data1x[]=mysql_result($Resultat , $seqno , "hittime");
}
mysql_close();
// Create the graph. These two calls are always required
$graph = new Graph(400,400,"auto");
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40,30,20,80);
// Create the bar plots
$b1plot = new BarPlot($data1y);
$b1plot->SetFillColor("orange");
$b1plot->value->Show();
// ...and add it to the graPH
$graph->Add($b1plot);
$graph->title->Set("Statistics: ");
$graph->xaxis->SetTickLabels($data1x);
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->title->Set("");
$graph->yaxis->title->Set("Number of connections");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
// Display the graph
$graph->Stroke();
?> |
Partager