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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph-3.5.0b1/src/jpgraph.php');
require_once ('jpgraph-3.5.0b1/src/jpgraph_line.php');
include ('connexion_bd.php');
$tabCheckbox = explode('|' , $_POST['donnees']);
foreach ($tabCheckbox as $key => $value)
{
$tabCheckbox[$key] = explode(',' , $value);
}
$req_euro = "SELECT SUM(e_ini) , SUM(e_fin) FROM tableau_bord ";
$where = "WHERE ";
$y = 0;
// keya clé petit tableau
// $tab valeur de mon tableau
foreach ($tabCheckbox as $keya => $tab)
{
// tableau priorite ok
/*if($keya == 0)
{ continue; }*/
$x = 0;
// separe les petits tableaux
if($y != 0)
{ $where .= " AND ";}
$where .= "( ";
foreach($tab as $value)
{
if($x == 0)
{$x++; continue; }
if ($x != 1)
// separe chaque valeur de petit tableau
$where .= "OR ";
if (($value == "Encours") || ($value == "Enattente") || ($value == "Termine")) {
switch ($value) {
case "Enattente":
$where .= $tab[0]."=0 ";
break;
case "Encours":
$where .= "(".$tab[0]." > 0 AND ".$tab[0]." < 100) ";
break;
case "Termine":
$where .= $tab[0]."=100 ";
break;
}
}
else {
$where .= $tab[0]."='".$value."' ";
}
$x++;
}
$where .= " ) ";
$y++;
}
$req_euro .= $where;
$query_euro = mysql_query($req_euro);
$array = mysql_fetch_array($query_euro);
$datay1 = array($array[0] ,$array[1], $array[0]);
$datay2 = array($array[0] ,$array[1], $array[0]);
$datay3 = array($array[0] ,$array[1], $array[0]);
// Setup the graph
$graph = new Graph(420,226);
$graph->SetScale("textlin");
$theme_class= new UniversalTheme;
$graph->SetTheme($theme_class);
$graph->xaxis->SetTickLabels(array(' initial',' current',' final'));
$graph->ygrid->SetFill(false);
$p1 = new LinePlot($datay1);
$graph->Add($p1);
$p2 = new LinePlot($datay2);
$graph->Add($p2);
$p3 = new LinePlot($datay3);
$graph->Add($p3);
$p1->SetColor("#01badc");
$p1->SetLegend('Exploitation');
$p1->mark->SetType(MARK_FILLEDCIRCLE,'',1.0);
$p1->mark->SetColor('#01badc');
$p1->mark->SetFillColor('#01badc');
$p1->SetCenter();
$p1->value->Show();
$p1->value->SetFormat('%d');
$p1->value->SetColor('#01badc');
$p2->SetColor("#f23d64");
$p2->SetLegend('Bâtiment');
$p2->mark->SetType(MARK_FILLEDCIRCLE,'',1.0);
$p2->mark->SetColor('#f23d64');
$p2->mark->SetFillColor('#f23d64');
$p2->SetCenter();
$p2->value->Show();
$p2->value->SetFormat('%d');
$p2->value->SetColor('#f23d64');
$p3->SetColor("#ffa800");
$p3->SetLegend('Infrastructure');
$p3->mark->SetType(MARK_FILLEDCIRCLE,'',1.0);
$p3->mark->SetColor('#ffa800');
$p3->mark->SetFillColor('#ffa800');
$p3->SetCenter();
$p3->value->Show();
$p3->value->SetFormat('%d');
$p3->value->SetColor('#ffa800');
$graph->legend->SetFrameWeight(1);
$graph->legend->SetColor('#4E4E4E','#00A78A');
$graph->legend->SetMarkAbsSize(8);
// Output line
$graph->Stroke('images/test.png'); |
Partager