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
| <?php
include ("../jpgraph/jpgraph.php");
include ("../jpgraph/jpgraph_bar.php");
define('MYSQL_HOST', 'localhost');
define('MYSQL_USER', 'root');
define('MYSQL_PASS', '');
define('MYSQL_DATABASE', 'glpi');
//$tableauouverttotal = "";
//$tableauresolutotal = "";
$tableauouverttotal = array();
$tableauresolutotal = array();
$tableaumois = array();
$sql = 'SELECT COUNT(ID) AS total_ouvert,
COUNT(solvedate) AS total_resolu,
MONTH(date) AS MOIS
FROM glpi_excel
WHERE date >= DATE_SUB("2012-06-01", INTERVAL 2 MONTH) AND date <= LAST_DAY("2012-06-01")
GROUP BY MONTH(date)';
$mysqlCnx = @mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) or die('Pb de connxion mysql');
@mysql_select_db(MYSQL_DATABASE) or die('Pb de sélection de la base');
$mysqlQuery = @mysql_query($sql, $mysqlCnx) or die('Pb de requête');
while ($row = mysql_fetch_array($mysqlQuery, MYSQL_ASSOC)) {
$tableauouverttotal[] = $row['total_ouvert'];
$tableauresolutotal[] = $row['total_resolu'];
$tableaumois[] = $row['MOIS'];
}
setlocale(LC_ALL, 'french');
echo strftime('%B',strtotime($tableaumois));
//var_dump($tableauouverttotal);
//var_dump($tableauresolutotal);
var_dump($tableaumois);
/*
// *******************
// Création du graphique
// *******************
// Construction du conteneur
// Spécification largeur et hauteur
$graph = new Graph(1000,500);
// Réprésentation linéaire
$graph->SetScale("textlin");
// Ajouter une ombre au conteneur
//$graph->SetShadow();
// Fixer les marges
$graph->img->SetMargin(60,30,25,140);
// Une ombre pour chaque barre
//$bplot->SetShadow();
// Chaque histogramme sera placé dans un tableau commun
$aGroupBarPlot = array();
//Histo 1
$bplot = new BarPlot($tableauouverttotal);
$aGroupBarPlot[] = $bplot;
//Histo 2
$bplot2 = new BarPlot($tableauresolutotal);
$aGroupBarPlot[] = $bplot2;
//Objet qui regroupe les histogrammes
$gbarplot = new GroupBarPlot($aGroupBarPlot);
// Fixer l'aspect de la police
$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,8);
// Modifier le rendu de chaque valeur
$bplot->value->SetFormat('%d');
// Fixer l'aspect de la police
$bplot2->value->SetFont(FF_ARIAL,FS_NORMAL,8);
// Modifier le rendu de chaque valeur
$bplot2->value->SetFormat('%d');
// Spécification des couleurs des barres
$bplot->SetFillColor('red');
$bplot2->SetFillColor('green');
$bplot->SetLegend("ticket ouverts");
$bplot2->SetLegend("ticket résolus");
// Couleur de l'ombre et du fond de la légende
$graph->legend->SetShadow('darkgray@0.5');
$graph->legend->SetFillColor('lightblue@0.3');
// Afficher les valeurs pour chaque barre
$bplot->value->Show();
$bplot2->value->Show();
// Le titre
$graph->title->Set("Nombre de tickets ouverts et résolus");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->legend->SetPos(0.50,0.9,'center');
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
// Légende pour l'axe horizontal
$graph->xaxis->SetTickLabels($tableaumois);
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8);
$graph->xaxis->SetLabelAngle(50);
// Ajouter au graphique les 2 histos
$graph->Add($gbarplot);
// Afficher le graphique
$graph->Stroke();
*/
?> |
Partager