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 31/03/2011, 14h20   #1
Membre régulier
 
Inscription : janvier 2009
Messages : 320
Détails du profil
Informations forums :
Inscription : janvier 2009
Messages : 320
Points : 90
Points : 90
Par défaut L'image ne peut pas être affichée car elle contient des erreurs

Bonjour à vous!
Je suis en train de suivre le tutoriel suivant :
http://eric-pommereau.developpez.com...aphiques#LII-D

L'objectif de ce tutoriel étant d'afficher, grâce à jpgraph, un histogramme. Au lieu de le suivre à la lettre j'ai tenté de faire quelques expérimentation personnelles. 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
 
 
<?php
 
			@include ("./jpgraph/src/jpgraph.php");
			@include ("./jpgraph/src/jpgraph_bar.php");
 
			$tableauPersonne = array("Pascal", "Régis", "Mathieu", "Anthony");
			$tableauNombreCD = array(55, 120, 12, 100);
 
			// Construction du conteneur
			// Spécification largeur et hauteur
			$graph = new Graph(400,250);
 
			// Réprésentation linéaire
			$graph->SetScale("textlin");
 
			// Ajouter une ombre au conteneur
			$graph->SetShadow();
 
			// Fixer les marges
			$graph->img->SetMargin(40,30,25,40);
 
			// Création du graphique histogramme
			$bplot = new BarPlot($tableauNombreCD);
 
			// Spécification des couleurs des barres
			$bplot->SetFillColor(array('red', 'green', 'blue', 'orange'));
 
			// Une ombre pour chaque barre
			$bplot->SetShadow();
 
			// Afficher les valeurs pour chaque barre
			$bplot->value->Show();
			// Fixer l'aspect de la police
			$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
			// Modifier le rendu de chaque valeur
			$bplot->value->SetFormat('%d ventes');
 
			// Ajouter les barres au conteneur
			$graph->Add($bplot);
 
			// Le titre
			$graph->title->Set("Graphique 'HISTOGRAMME' : nombre de CD par personnes");
			$graph->title->SetFont(FF_FONT1,FS_BOLD);
 
			// Titre pour l'axe horizontal(axe x) et vertical (axe y)
			$graph->xaxis->title->Set("Personnes");
			$graph->yaxis->title->Set("Nombre de CD");
 
			$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($tableauPersonne);
 
			// Afficher le graphique
			$graph->Stroke();
		?>
Lorsque je teste, voici l'erreur : L'image http://localhost/TEST/ ne peut pas être affiché car elle contient des erreurs.
En mettant $graph->Stroke(); en commentaires, je n'ai plus d'erreur. Avez vous des idées ?

Merci =)
Redg9 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 07h42   #2
Membre du Club
 
Homme Clément Viguié
Technicien SIG
Inscription : janvier 2011
Messages : 37
Détails du profil
Informations personnelles :
Nom : Homme Clément Viguié
Âge : 27
Localisation : France

Informations professionnelles :
Activité : Technicien SIG
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : janvier 2011
Messages : 37
Points : 42
Points : 42
Bonjour,
Quand je copie colle ton code et remplace mes chemins pour accéder aux fichiers jpgraph ca marche très bien... Vérifie tes chemins:
Code :
1
2
3
4
5
 
@include ("./jpgraph/src/jpgraph.php");
//remplace par
@include ("../jpgraph/src/jpgraph.php");
//il te manque un point dans le chemin relatif
Ensuite tu travaille avec quelle version de jpghraph en local ou directement sur un serveur ?
Vérifier qu'il n'y a aucun code html avant et après tes balises php et
Enlève aussi tous les espaces saut de ligne avant et après les balises ,<?php doit être ton premier caractère et ?> le dernier,
ensuite ca devrait rouler
Clément FREDON est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 09h16   #3
Membre régulier
 
Inscription : janvier 2009
Messages : 320
Détails du profil
Informations forums :
Inscription : janvier 2009
Messages : 320
Points : 90
Points : 90
Bonjour clément et merci pour ta réponse,
Tu me dis que s'il y a du code html avant cela ne peut pas fonctionner ?
Voici dans ce cas mon code complet (j'aurais du faire ca depuis le début^^)
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
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
131
132
133
134
135
136
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
   <head>
       <title>Mon super site</title>
       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	   <link href="design.css" rel="stylesheet" type="text/css" media="screen, handheld, tv, projection" />
   </head>
 
   <body>
 
		<?php
 
			$tableauPersonne = array();
			$tableauNombreCD = array();
			$tableauAge = array();
 
			try
			{
 
				$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
				$bdd = new PDO('mysql:host=localhost;dbname=maBase', 'root', '', $pdo_options);
 
 
				$reponse = $bdd->query('SELECT * FROM personne');
 
				// On affiche chaque entrée une à une
				while ($donnees = $reponse->fetch())
				{
					$tableauPersonne[] = $donnees['nom'];
					$tableauAge[] = $donnees['age'];
					$tableauNombreCD[] = $donnees['nombre_cd'];
				}
					$reponse->closeCursor(); // Termine le traitement de la requête
			}
			catch (Exception $e)
			{
					die('Erreur : ' . $e->getMessage());
			}
 
		?>
		<table id="table">
			<caption class = "caption">Valeurs à mettre dans le graphique</caption>
 
			<tr id="id">
				<td>Nom</td>
				<td>Age</td>
				<td>nombre de CD</td>
			</tr>
 
			<tr class = "personne">
				<td><?php print_r($tableauPersonne[0]); ?></td>
				<td><?php print_r($tableauAge[0]); ?></td>
				<td><?php print_r($tableauNombreCD[0]); ?></td>
			</tr>
 
			<tr class = "personne">
				<td><?php print_r($tableauPersonne[1]); ?></td>
				<td><?php print_r($tableauAge[1]); ?></td>
				<td><?php print_r($tableauNombreCD[1]); ?></td>
			</tr>
 
			<tr class = "personne">
				<td><?php print_r($tableauPersonne[2]); ?></td>
				<td><?php print_r($tableauAge[2]); ?></td>
				<td><?php print_r($tableauNombreCD[2]); ?></td>
			</tr>
 
			<tr class = "personne">
				<td><?php print_r($tableauPersonne[3]); ?></td>
				<td><?php print_r($tableauAge[3]); ?></td>
				<td><?php print_r($tableauNombreCD[3]); ?></td>
			</tr>
 
		</table>
 
 
 
		<?php	
 
			@include ("./jpgraph/src/jpgraph.php");
			@include ("./jpgraph/src/jpgraph_bar.php");
 
			// Construction du conteneur
			// Spécification largeur et hauteur
			$graph = new Graph(400,250);
 
			// Réprésentation linéaire
			$graph->SetScale("textlin");
 
			// Ajouter une ombre au conteneur
			//$graph->SetShadow();
 
			// Fixer les marges
			$graph->img->SetMargin(40,30,25,40);
 
			// Création du graphique histogramme
			$bplot = new BarPlot($tableauNombreCD);
 
			// Spécification des couleurs des barres
			$bplot->SetFillColor(array('red', 'green', 'blue', 'orange'));
 
			// Une ombre pour chaque barre
			//$bplot->SetShadow();
 
			// Afficher les valeurs pour chaque barre
			$bplot->value->Show();
			// Fixer l'aspect de la police
			$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
			// Modifier le rendu de chaque valeur
			$bplot->value->SetFormat('%d personne');
 
			// Ajouter les barres au conteneur
			$graph->Add($bplot);
 
			// Le titre
			$graph->title->Set("Graphique 'HISTOGRAMME' : nombre de CD par personnes");
			$graph->title->SetFont(FF_FONT1,FS_BOLD);
 
			// Titre pour l'axe horizontal(axe x) et vertical (axe y)
			$graph->xaxis->title->Set("Personnes");
			$graph->yaxis->title->Set("Nombre de CD");
 
			$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($tableauPersonne);
 
			// Afficher le graphique
			$graph->Stroke();
		?>
 
    </body>
</html>
Comme tu peux le constater, il y a du code html avant et après. La solution serait de mettre mon code php dans un autre fichier et faire un appel dans le fichier html ?

Merci.
Redg9 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 10h23   #4
Membre du Club
 
Homme Clément Viguié
Technicien SIG
Inscription : janvier 2011
Messages : 37
Détails du profil
Informations personnelles :
Nom : Homme Clément Viguié
Âge : 27
Localisation : France

Informations professionnelles :
Activité : Technicien SIG
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : janvier 2011
Messages : 37
Points : 42
Points : 42
Essaye d'abord de créer un fichier php juste avec tes balises sans espaces ni rien avant ni apres... et cela devrait marcher
Clément FREDON est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 10h39   #5
Membre régulier
 
Inscription : janvier 2009
Messages : 320
Détails du profil
Informations forums :
Inscription : janvier 2009
Messages : 320
Points : 90
Points : 90
toujours la même erreur. Et l'adresse des include est bonne également
Redg9 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 10h46   #6
Membre du Club
 
Homme Clément Viguié
Technicien SIG
Inscription : janvier 2011
Messages : 37
Détails du profil
Informations personnelles :
Nom : Homme Clément Viguié
Âge : 27
Localisation : France

Informations professionnelles :
Activité : Technicien SIG
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : janvier 2011
Messages : 37
Points : 42
Points : 42
Tu as bien enlever tous les espaces ou retour a la ligne?
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
<?php
 
			Include('../jpgraph/src/jpgraph.php');
			Include ('../jpgraph/src/jpgraph_bar.php');
 
			$tableauPersonne = array("Pascal", "Régis", "Mathieu", "Anthony");
			$tableauNombreCD = array(55, 120, 12, 100);
 
			// Construction du conteneur
			// Spécification largeur et hauteur
			$graph = new Graph(400,250);
 
			// Réprésentation linéaire
			$graph->SetScale("textlin");
 
			// Ajouter une ombre au conteneur
			$graph->SetShadow();
 
			// Fixer les marges
			$graph->img->SetMargin(40,30,25,40);
 
			// Création du graphique histogramme
			$bplot = new BarPlot($tableauNombreCD);
 
			// Spécification des couleurs des barres
			$bplot->SetFillColor(array('red', 'green', 'blue', 'orange'));
 
			// Une ombre pour chaque barre
			$bplot->SetShadow();
 
			// Afficher les valeurs pour chaque barre
			$bplot->value->Show();
			// Fixer l'aspect de la police
			$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
			// Modifier le rendu de chaque valeur
			$bplot->value->SetFormat('%d ventes');
 
			// Ajouter les barres au conteneur
			$graph->Add($bplot);
 
			// Le titre
			$graph->title->Set("Graphique 'HISTOGRAMME' : nombre de CD par personnes");
			$graph->title->SetFont(FF_FONT1,FS_BOLD);
 
			// Titre pour l'axe horizontal(axe x) et vertical (axe y)
			$graph->xaxis->title->Set("Personnes");
			$graph->yaxis->title->Set("Nombre de CD");
 
			$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($tableauPersonne);
 
			// Afficher le graphique
			$graph->Stroke();
		?>
Copie juste et colle au début du fichier sans espace sans de saut de ligne etc...
Clément FREDON est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 10h47   #7
Membre régulier
 
Inscription : janvier 2009
Messages : 320
Détails du profil
Informations forums :
Inscription : janvier 2009
Messages : 320
Points : 90
Points : 90
Création d'un nouveau document php, avec le code suivant. Avec ou sans espace ca donne la même chose

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
 
<?php	
 
	@include ("./jpgraph/src/jpgraph.php");
	@include ("./jpgraph/src/jpgraph_bar.php");
 
	$tableauPersonne = array("Régis", "Anthony", "Mathieu", "Pascal");
	$tableauNombreCD = array(10, 25, 2, 55);
 
	// Construction du conteneur
	// Spécification largeur et hauteur
	$graph = new Graph(400,250);
 
	// Réprésentation linéaire
	$graph->SetScale("textlin");
 
	// Ajouter une ombre au conteneur
	//$graph->SetShadow();
 
	// Fixer les marges
	$graph->img->SetMargin(40,30,25,40);
 
	// Création du graphique histogramme
	$bplot = new BarPlot($tableauNombreCD);
 
	// Spécification des couleurs des barres
	$bplot->SetFillColor(array('red', 'green', 'blue', 'orange'));
 
	// Une ombre pour chaque barre
	//$bplot->SetShadow();
 
	// Afficher les valeurs pour chaque barre
	$bplot->value->Show();
	// Fixer l'aspect de la police
	$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
	// Modifier le rendu de chaque valeur
	$bplot->value->SetFormat('%d personne');
 
	// Ajouter les barres au conteneur
	$graph->Add($bplot);
 
	// Le titre
	$graph->title->Set("Graphique 'HISTOGRAMME' : nombre de CD par personnes");
	$graph->title->SetFont(FF_FONT1,FS_BOLD);
 
	// Titre pour l'axe horizontal(axe x) et vertical (axe y)
	$graph->xaxis->title->Set("Personnes");
	$graph->yaxis->title->Set("Nombre de CD");
 
	$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($tableauPersonne);
 
	// Afficher le graphique
	$graph->Stroke();
?>
Redg9 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 11h13   #8
Membre régulier
 
Inscription : janvier 2009
Messages : 320
Détails du profil
Informations forums :
Inscription : janvier 2009
Messages : 320
Points : 90
Points : 90
Je pense que mon problème ne vient pas du code. J'ai tenté d'ouvrir les exemples, cela n'a pas fonctionné avec la même erreur. Je me suis posé alors la question de la qualité de l'installation. Vu sur développez, l'installation était bonne.
Avec ce site http://nikhun.com/?p=362 toujours pas de solution..

Des conseils pour valider l'installation de jpgraph ?

Cdt.
Redg9 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 11h31   #9
Membre du Club
 
Homme Clément Viguié
Technicien SIG
Inscription : janvier 2011
Messages : 37
Détails du profil
Informations personnelles :
Nom : Homme Clément Viguié
Âge : 27
Localisation : France

Informations professionnelles :
Activité : Technicien SIG
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : janvier 2011
Messages : 37
Points : 42
Points : 42
TU rajoutes les sauts de ligne dans le message pour faire plus clair ou ton fichier commence par un saut de ligne et se finit par deux saut de ligne
Clément FREDON est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 11h32   #10
Membre du Club
 
Homme Clément Viguié
Technicien SIG
Inscription : janvier 2011
Messages : 37
Détails du profil
Informations personnelles :
Nom : Homme Clément Viguié
Âge : 27
Localisation : France

Informations professionnelles :
Activité : Technicien SIG
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : janvier 2011
Messages : 37
Points : 42
Points : 42
Ton jpgraph est bien installé car sinon il te dirait que chaque fonction propre à la bibliothèque jpgraph n'existerait pas
Clément FREDON est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 11h57   #11
Membre régulier
 
Inscription : janvier 2009
Messages : 320
Détails du profil
Informations forums :
Inscription : janvier 2009
Messages : 320
Points : 90
Points : 90
c'est pour faire plus clair
Redg9 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 12h05   #12
Membre du Club
 
Homme Clément Viguié
Technicien SIG
Inscription : janvier 2011
Messages : 37
Détails du profil
Informations personnelles :
Nom : Homme Clément Viguié
Âge : 27
Localisation : France

Informations professionnelles :
Activité : Technicien SIG
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : janvier 2011
Messages : 37
Points : 42
Points : 42
As tu essayé des exemples du site jpgraph?
QUelv ersion de jpgraph utilises tu?
EN local ou pas?
Clément FREDON est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 12h34   #13
Membre régulier
 
Inscription : janvier 2009
Messages : 320
Détails du profil
Informations forums :
Inscription : janvier 2009
Messages : 320
Points : 90
Points : 90
Sur les exemples, j'ai la même erreur.
Je peux déterminer la version ou ? Dans le fichier Version.txt ? Il me donne ceci :
Code :
1
2
Revision: r1089, Exported: 2009-01-31 15:55
Patchlevel: 1 : Correction of font path typo.
Je suis en local (j'utilise wamp)
PHP 5.3
Redg9 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 12h42   #14
Membre du Club
 
Homme Clément Viguié
Technicien SIG
Inscription : janvier 2011
Messages : 37
Détails du profil
Informations personnelles :
Nom : Homme Clément Viguié
Âge : 27
Localisation : France

Informations professionnelles :
Activité : Technicien SIG
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : janvier 2011
Messages : 37
Points : 42
Points : 42
Ben télécharge une version ur jpgraph remplace ton dossier jpgraph par celui ci et ressaye moi ton fichier marche sur les deux dernières versions
Clément FREDON est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 01/04/2011, 13h06   #15
Membre régulier
 
Inscription : janvier 2009
Messages : 320
Détails du profil
Informations forums :
Inscription : janvier 2009
Messages : 320
Points : 90
Points : 90
C'était bien une histoire de version.

Merci pour ta réponse et ta patience

=)

Problème résolu.
Redg9 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/04/2011, 13h12   #16
Membre du Club
 
Homme Clément Viguié
Technicien SIG
Inscription : janvier 2011
Messages : 37
Détails du profil
Informations personnelles :
Nom : Homme Clément Viguié
Âge : 27
Localisation : France

Informations professionnelles :
Activité : Technicien SIG
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : janvier 2011
Messages : 37
Points : 42
Points : 42
Ravi de t'avoir aidé,
Bonne journée
Clément FREDON est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 03h53.


 
 
 
 
Partenaires

Hébergement Web