par
mif » 05 mai 2016, 19:21
Bonsoir ;
J'ai besoin de créer des graphiques avec heure (HH:mm) ou en minute(mm:ss) en abscisse .. voila le code
<?php
/// le nom de serveur
$serverName = 'MIFTAHA-PC\WINCCFLEXEXPRESS';
/// Choix de la base de données
$connectionInfo = array('Database' => 'base1');
/// Connexion avec le serveur
$conn = sqlsrv_connect( $serverName, $connectionInfo);
/// test de connexion
/*if( $conn ) {
echo "Connexion etablie.<br /><hr>";
}else{
echo "La connexion n'a pu être établie.<br />";
die( print_r( sqlsrv_errors(), true));}*/
/// selectionner des données à importer
$qr ='SELECT * FROM table1';
$stmp=sqlsrv_query($conn,$qr);
if($stmp){
}
/// affichage des données
$i = 0;
while($rows=sqlsrv_fetch_array($stmp)){ $Hour[]=$rows['heure']; }// heure est sous forme date (y-m-d HH:mm) je veux extraire que l'heure
// content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$datay=array(20,22,12,13,17,20,16,19,30,31,40,43);
/// Create the graph. These two calls are always required
$graph = new Graph(450,200,'auto');
$graph->SetScale('intlin');
/// Add a drop shadow
$graph->SetShadow();
// /Adjust the margin a bit to make more room for titles
$graph->SetMargin(40,30,50,40);
/// Create a bar pot
//$a = array(22145,2125,31475,41454);
$graph->xaxis->SetTickLabels($hour);
$bplot = new BarPlot($datay);//
/// Adjust fill color
$bplot->SetFillColor('orange');
$graph->Add($bplot);
/// Setup the titles
$graph->title->Set('Pluie en mm');
$graph->yaxis->title->Set('volume de pluie en mm');
$graph->xaxis->title->Set('Date');
$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();
?>
Bonsoir ;
J'ai besoin de créer des graphiques avec heure (HH:mm) ou en minute(mm:ss) en abscisse .. voila le code
[php]<?php
/// le nom de serveur
$serverName = 'MIFTAHA-PC\WINCCFLEXEXPRESS';
/// Choix de la base de données
$connectionInfo = array('Database' => 'base1');
/// Connexion avec le serveur
$conn = sqlsrv_connect( $serverName, $connectionInfo);
/// test de connexion
/*if( $conn ) {
echo "Connexion etablie.<br /><hr>";
}else{
echo "La connexion n'a pu être établie.<br />";
die( print_r( sqlsrv_errors(), true));}*/
/// selectionner des données à importer
$qr ='SELECT * FROM table1';
$stmp=sqlsrv_query($conn,$qr);
if($stmp){
}
/// affichage des données
$i = 0;
while($rows=sqlsrv_fetch_array($stmp)){ $Hour[]=$rows['heure']; }// heure est sous forme date (y-m-d HH:mm) je veux extraire que l'heure
// content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$datay=array(20,22,12,13,17,20,16,19,30,31,40,43);
/// Create the graph. These two calls are always required
$graph = new Graph(450,200,'auto');
$graph->SetScale('intlin');
/// Add a drop shadow
$graph->SetShadow();
// /Adjust the margin a bit to make more room for titles
$graph->SetMargin(40,30,50,40);
/// Create a bar pot
//$a = array(22145,2125,31475,41454);
$graph->xaxis->SetTickLabels($hour);
$bplot = new BarPlot($datay);//
/// Adjust fill color
$bplot->SetFillColor('orange');
$graph->Add($bplot);
/// Setup the titles
$graph->title->Set('Pluie en mm');
$graph->yaxis->title->Set('volume de pluie en mm');
$graph->xaxis->title->Set('Date');
$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();
?>[/php]