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 72 73 74 75 76
| <?php
$sql = 'SELECT Date, Chauffage, Eclairage, Cuisine, Medias, Autres FROM tbl_data';
print_r(mysql_error());
$req = mysql_query($sql);
while ( ($data = mysql_fetch_assoc($req))!== false) {
$conso1[] = $data['Chauffage'];
$conso2[] = $data['Cuisine'];
$conso3[] = $data['Eclairage'];
$conso4[] = $data['Medias'];
$conso5[] = $data['Autres'];
$dates[] = $data['Date'];
}
/* JPgraph */
require_once ('src/jpgraph.php');
require_once ('src/jpgraph_line.php');
require_once("src/jpgraph_date.php");
// Setup the graph
$graph = new Graph(10000,500);
$graph->SetScale("textlin");
//$theme_class=new UniversalTheme;
$theme_class=new AquaTheme;
$graph->SetTheme($theme_class);
$graph->img->SetAntiAliasing(false);
$graph->title->Set('Evolution de la consommation');
$graph->SetBox(false);
$graph->img->SetAntiAliasing();
$graph->yaxis->HideZeroLabel();
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);
$graph->xgrid->Show();
$graph->xgrid->SetLineStyle("solid");
$graph->xaxis->SetTickLabels($dates); // l'axe du bas
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,6);
$graph->xgrid->SetColor('#E3E3E3');
// Les lignes
$p1 = new LinePlot($conso1);
$graph->Add($p1);
$p1->SetColor("#B254FF");
$p1->SetLegend('Eclairage');
$p1 = new LinePlot($conso2);
$graph->Add($p1);
$p1->SetColor("#38FFFF");
$p1->SetLegend('MenageCuisine');
$p1 = new LinePlot($conso3);
$graph->Add($p1);
$p1->SetColor("#3019FF");
$p1->SetLegend('MenageLavage');
$p1 = new LinePlot($conso4);
$graph->Add($p1);
$p1->SetColor("#90FF00");
$p1->SetLegend('PetitMenage');
$p1 = new LinePlot($conso5);
$graph->Add($p1);
$p1->SetColor("#FF8300");
$p1->SetLegend('LoisirBureau');
$graph->legend->SetFrameWeight(1);
// Output line
$graph->Stroke();
?> |
Partager