Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > Images > JpGraph
JpGraph Forum d'entraide pour la bibliothèque JpGraph permettant de manipuler des images en PHP. Avant de poster -> tutoriels JpGraph
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 22/11/2011, 14h15   #1
Invité de passage
 
Homme
Ingénieur systèmes et réseaux
Inscription : novembre 2011
Messages : 8
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Ingénieur systèmes et réseaux
Secteur : Industrie

Informations forums :
Inscription : novembre 2011
Messages : 8
Points : 4
Points : 4
Par défaut problème histogramme groupé

Bonjour à tous,

Je chercher à créer un histogramme groupé avec jpgraph et je galère depuis plusieurs jours.

Voici mon code :
Code :
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
 
<?php
include ("c:\wamp\www\jpgraph\jpgraph.php");
include ("c:\wamp\www\jpgraph\jpgraph_bar.php");
 
	// Quelques données
// Quelques données
$taleau = array();
 
$mois=array();
	$querydate =  mysql_query("select id, date from graph");
	while ($date =   mysql_fetch_array($querydate,  MYSQL_ASSOC)) {
	$mois[$date['id']-1] = $date['date'];}
 
 
//récupération des dates
$sqldate = "select date 
from graph";
 
// pour chaque date on récupère les infos applications
$sqlinfo = "select app_tt 
from graph 
where date = '%s'";
 
$sqlinfo2 = "select app_tr 
from graph 
where date = '%s'";
 
$query = mysql_query($sqldate);
 
 
while ($row_date = mysql_fetch_array($query, MYSQL_ASSOC)){
$tableau[$row_date['date']] = array ();
$date=$row_date['date'];
 
$query2 = mysql_query(sprintf($sqlinfo, $date)) or die ('erreur 1');
 
$query3 = mysql_query(sprintf($sqlinfo2, $date)) or die ('erreur 2');
 
 
	while ($row_info = mysql_fetch_array($query2, MYSQL_ASSOC)){
	$tableau[$date][0]= $row_info['app_tt'];
	}	
	while ($row_info2 = mysql_fetch_array($query3, MYSQL_ASSOC)){
	$tableau[$date][1]= $row_info2['app_tr'];
	}
 
}
 
// Creation du graphique. Ces deux fonctions sont obligatoirement utilisées
$graph = new Graph(640,480,"auto");    
$graph->SetScale("textlin");
 
// Ajouter le titre du graphique
$graph->title->Set("Histogrammes des applications");
 
// Obtenir le mois (localisation fr possible ?)
$graph->xaxis->SetTickLabels($mois);
 
// AXE X
$graph->xaxis->title->Set('Date');
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetColor('black');
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetColor('black');
 
// AXE Y
$graph->yaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->SetColor('black');
$graph->ygrid->SetColor('black@0.5');
 
// Couleurs et transparence par histogramme
$aColors=array('red@0.4', 'blue@0.4', 'green@0.4', 'pink@0.4', 'teal@0.4', 'navy@0.4');
 
$i=0;
 
// Chaque  histogramme est un élément du tableau:
$aGroupBarPlot = array();
 
foreach ($tableau as $key => $value) {
	$bplot = new BarPlot($tableau[$key]);
	$bplot->SetFillColor($aColors[$i++]);
	$bplot->SetLegend($key);
	$bplot->SetShadow('black@0.4');
	$aGroupBarPlot[] = $bplot; 
}
 
// Création de l'objet qui regroupe nos histogrammes
$gbarplot = new GroupBarPlot($aGroupBarPlot);
$gbarplot->SetWidth(0.8);
 
// Ajouter au graphique
$graph->Add($gbarplot);
 
// Affichage du graphique
$graph->Stroke();
 
?>
si j'affiche mon tableau de valeur j'obtiens :
Array ( [17-11-2011] => Array ( [0] => 132 [1] => 18 ) [18-11-2011] => Array ( [0] => 132 [1] => 19 ) )
c'est ce que je voudrais afficher à savoir pour une date les deux valeurs du tableau, mais jpgraph m'affiche les deux valeurs 0 l'une à coté de l'autre.
Je n'arrives pas à trouver la bonne requête ou comment faire pour que jpgraph utilise comme il le faut mon tableau.

Si vous avez des idées je suis preneur.
franck10 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 17h17.


 
 
 
 
Partenaires

Hébergement Web