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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| <?php
include ("jpgraph-4.3.5/src/jpgraph.php");
include ("jpgraph-4.3.5/src/jpgraph_line.php");
/* connexion sgbd a ne pas oublier */
$host = "127.0.0.1"; /* L'adresse du serveur */
$login = "root"; /* Votre nom d'utilisateur */
$password = ""; /* Votre mot de passe */
$base = "boite_noire"; /* Le nom de la base */
/*/function connexion()
{
global $host, $login, $password, $base;
$db = mysql_connect($host, $login, $password);
mysql_select_db($base,$db);
}
$sql = 'select moteur from Essence,Date_de_moteur,ID_moteur;';
$req = mysql_query($sql);
while ( ($data = mysql_fetch_assoc($req))!== false) {
$xdata[] = $data['ID_moteur'];
$ydata[] = $data['Essence'];
$zdata[] = $data['Date_de_moteur'];
}*/
// Fonction de connexion
$dbh = new PDO('mysql:host=localhost;dbname=boite_noire', $login, $password);
// use the connection here // Selection de la table apres la connexion
$sth = $dbh->query('SELECT * FROM moteur');
// fetch all rows into array, by default PDO::FETCH_BOTH is used //
$rows = $sth->fetchAll();
// iterate over array by index and by name //
foreach($rows as $row) {
//echo $row['ID_moteur']." ".$row['Essence']." ".$row['Date_de_moteur']."<br />\n";
//printf("$row['ID_moteur'] $row['Essence'] $row['Datedemoteur'] \n");
$xdata[] = $row['Date_de_moteur'];
$Toursdata[] = $row['Tours'];
$Essencedata[] = $row['Essence'];
$Vitessedata[] = $row['Vitesse'];
}
$graph = new Graph(500,300,"auto");
$graph->SetScale("textlin");
$graph->img->SetMargin(40,40,40,50);
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetTickLabels($xdata);
$graph->title->Set("Phoebus1");
$lineplot=new LinePlot($Toursdata);
$lineplot->SetColor("green");
$lineplot1=new LinePlot($Vitessedata);
$lineplot->SetColor("blue");
$lineplot2=new LinePlot($Essencedata);
$lineplot2->SetColor("red");
$lineplot->SetLegend("Tour");
$lineplot1->SetLegend("Vitesse");
$lineplot2->SetLegend("Essence");
$graph->Add($lineplot2);
$graph->Add($lineplot1);
$graph->Add($lineplot);
$graph->Stroke();
?> |
Partager