Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > Images > Artichow
Artichow Forum d'entraide pour la bibliothèque Artichow permettant de manipuler des images en PHP.
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 25/09/2008, 17h27   #1
Membre régulier
 
Inscription : mars 2006
Messages : 189
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 189
Points : 99
Points : 99
Envoyer un message via MSN à spax
Par défaut Image s'affiche en ASCII ? artichow et fichier ?

Bonjour bon voila encore un problème sans solution :
ce que je veut faire est simple : générer l'image au click sur un boutton mais pas pour autant rechercher la page actuelle :s

et apré je peut jouer avec l'image générer comme je veut .

je teste alors avec un des exemple présent sur le site de artichow :

mon fichier script.php

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
<?php
require_once "plots/BarPlot.class.php";
 
function plot()
{
 
   $graph = new Graph(400, 300);
   $graph->setAntiAliasing(TRUE);
 
   // On déclare une couleur bleue...
   $blue = new Color(0, 0, 200);
   // ... et une rouge
   $red = new Color(200, 0, 0);
   $group = new PlotGroup();
	// On agrandit un peu les marges à gauche et à droite
	// Cela permettra d'afficher correctement un titre sur les axes
   $group->setPadding(40, 40);
   // On ajoute une couleur de fond à ce groupe de Plot
   $group->setBackgroundColor(
      new Color(240, 240, 240)
   );
   $values = array(12, 8, 20, 32, 15, 5);
   // L'histogramme est le premier « 1 » de deux « 2 » à afficher.
   $plot = new BarPlot($values, 1, 2);
   // Le fond des barres sera bleue
   $plot->setBarColor($blue);
   // L'axe de gauche sera l'axe de référence pour cet histogramme
   // Si vous utilisez Artichow pour PHP 4 & 5, transformez Plot::LEFT en PLOT_LEFT
   $plot->setYAxis(Plot::LEFT);
   $group->add($plot);
   // L'axe sera bleu
   $group->axis->left->setColor($blue);
   // Et on lui donne un titre...
   $group->axis->left->title->set("Operating systems");
   $values = array(6, 12, 14, 2, 11, 7);
   // L'histogramme est le second « 2 » de deux « 2 » à afficher.
   $plot = new BarPlot($values, 2, 2);
   // Le fond des barres sera rouge
   $plot->setBarColor($red);
   // L'axe de droite sera l'axe de référence pour cet histogramme
   // Si vous utilisez Artichow pour PHP 4 & 5, transformez Plot::RIGHT en PLOT_RIGHT
   $plot->setYAxis(Plot::RIGHT);
 
   // On ajoute l'histogramme au groupe
   $group->add($plot);
   // ... et l'axe sera rouge
   $group->axis->right->setColor($red);
   // Et on lui donne un titre...
   $group->axis->right->title->set("ClearCase Versions");
   $graph->add($group);
   $image = $graph->draw("filename.png);
}
 
 
?>
et je veut l'appeler sur un autre fichier php

execute.php
Code :
1
2
3
4
5
6
7
8
<?php
 
include("scripts\script.php");
 
plot();
 
 
?>
et la le souci c'est aucun fichier de créer et j'ai le code ASCII de l'image qui s'affiche à l'écran pourtant j'ai précisé un fichier dans draw

merci pour votre aide
spax est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/09/2008, 21h12   #2
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 383
Points : 16 383
include insere le contenu du fichier inclus.
tout te retrouves donc avec le contenu binaire de ton imagE.

pour afficher une image en HTML c'est <img>
Code :
echo '<img src="scripts\script.php">';
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 09h40   #3
Membre régulier
 
Inscription : mars 2006
Messages : 189
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 189
Points : 99
Points : 99
Envoyer un message via MSN à spax
Merci pour la réponse mais ca ne marche pas chez moi
en faisant :

Code :
1
2
 
echo '<img src="scripts\script.php">';
ceci n'execute pas le code de script.php :s .
ce que je veut faire c'est par exemple je génére l'image a l'instant ou je veut ( sous une action ) et je vois pas pourquoi il m'afficherai le code ASCII sachant que j'ai fait un include simple et j'ai même pas appelé la fonction pour l'executé :s

j'ai l'impression que ce fichier :
Code :
1
2
 
require_once "plots/BarPlot.class.php";
qui est inclue pour les fonctions de la construction du graphe fait deja plein d'affichage
spax est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 09h52   #4
Membre régulier
 
Inscription : mars 2006
Messages : 189
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 189
Points : 99
Points : 99
Envoyer un message via MSN à spax
Je reformule :

si j'ai mon script qui génére l'image :

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
 
<?php
require_once "plots/BarPlot.class.php";
 
function plot()
{
 
   $graph = new Graph(400, 300);
   $graph->setAntiAliasing(TRUE);
 
   // On déclare une couleur bleue...
   $blue = new Color(0, 0, 200);
   // ... et une rouge
   $red = new Color(200, 0, 0);
   $group = new PlotGroup();
	// On agrandit un peu les marges à gauche et à droite
	// Cela permettra d'afficher correctement un titre sur les axes
   $group->setPadding(40, 40);
   // On ajoute une couleur de fond à ce groupe de Plot
   $group->setBackgroundColor(
      new Color(240, 240, 240)
   );
   $values = array(12, 8, 20, 32, 15, 5);
   // L'histogramme est le premier « 1 » de deux « 2 » à afficher.
   $plot = new BarPlot($values, 1, 2);
   // Le fond des barres sera bleue
   $plot->setBarColor($blue);
   // L'axe de gauche sera l'axe de référence pour cet histogramme
   // Si vous utilisez Artichow pour PHP 4 & 5, transformez Plot::LEFT en PLOT_LEFT
   $plot->setYAxis(Plot::LEFT);
   $group->add($plot);
   // L'axe sera bleu
   $group->axis->left->setColor($blue);
   // Et on lui donne un titre...
   $group->axis->left->title->set("Operating systems");
   $values = array(6, 12, 14, 2, 11, 7);
   // L'histogramme est le second « 2 » de deux « 2 » à afficher.
   $plot = new BarPlot($values, 2, 2);
   // Le fond des barres sera rouge
   $plot->setBarColor($red);
   // L'axe de droite sera l'axe de référence pour cet histogramme
   // Si vous utilisez Artichow pour PHP 4 & 5, transformez Plot::RIGHT en PLOT_RIGHT
   $plot->setYAxis(Plot::RIGHT);
 
   // On ajoute l'histogramme au groupe
   $group->add($plot);
   // ... et l'axe sera rouge
   $group->axis->right->setColor($red);
   // Et on lui donne un titre...
    $group->axis->right->title->set("ClearCase Versions");
    $graph->add($group);
   $filename = 'myFile.png'; // on créer un nom de fichier
   /*
	* Par défaut la méthode draw va afficher directement le graphique. Cependant, si on a déjà affiché des données
	* à l'écran, le résultat est inutile. On enregistre donc l'image dans un fichier grâce à file_put_contents et le paramètre
	* Graph::DRAW_RETURN
	*/
	file_put_contents($filename, $graph->draw(Graph::DRAW_RETURN));
 
}
 
?>

puis mon script de teste simple :

Code :
1
2
3
4
5
6
7
8
9
 
<?php
 
include("scripts\plot.php");
 
plot();
 
 
?>
l'image est généré et rien n'est afficher a l'ecran ( d'ailleur j'aimerai bien que l'action soit masqué ==> pas de rechargement de la page actuelle

et la les cas que j'ai tester et sans résultat

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
 
//le même code qu'avant mais on ajoute d'autre script !!
<?php
 
include("scripts\plot.php");
 
plot();
 
 
?>
 
+
 autre scripts PHP
resultat le binaire afficher

d'ailleur j'enléve carement l'appel a PLOT() et j'ai encore le binaire ce qui me parait pas trop normal :s


inclure mon simple fichier test dans une autre page ==> pareil le binaire s'affiche ... pourtant aucun affichage n'est demandé .

j'ai même mis juste le include :
require_once "plots/BarPlot.class.php";
et le binaire d'afficher

ps : BarPlot.class.php est une classe de la librairie artichow :s

je suis dans l'impasse :s
spax est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 10h22   #5
Modérateur
 
Avatar de ThomasR
 
Homme Thomas Rambaud
Développeur Web
Inscription : décembre 2007
Messages : 2 140
Détails du profil
Informations personnelles :
Nom : Homme Thomas Rambaud
Âge : 25
Localisation : France

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : décembre 2007
Messages : 2 140
Points : 2 885
Points : 2 885
/*
* Par défaut la méthode draw va afficher directement le graphique. Cependant, si on a déjà affiché des données
* à l'écran, le résultat est inutile. On enregistre donc l'image dans un fichier grâce à file_put_contents et le paramètre
* Graph:RAW_RETURN
*/
Si tu lisais les commentaires de ton code il est écrit que si des données on déjà était affichées à l'écran (ce que je suppose puisque tu dis appeler d'autes scripts avant celui ci), l'image ne s'affichera pas.

De plus, on voit clairement que l'image est enregistrée dans myFile.png, donc, si tu veux afficher l'image

<img src="myFile.png" alt="Visuel de"/>
ThomasR est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 10h32   #6
Modérateur
 
Avatar de ThomasR
 
Homme Thomas Rambaud
Développeur Web
Inscription : décembre 2007
Messages : 2 140
Détails du profil
Informations personnelles :
Nom : Homme Thomas Rambaud
Âge : 25
Localisation : France

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : décembre 2007
Messages : 2 140
Points : 2 885
Points : 2 885
Sinon vu que dans le cas contraire la méthode affiche juste le graphique, ta page php doit avoir une entête d'image.

header("Content-type: image/png");
ThomasR est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 10h32   #7
Membre régulier
 
Inscription : mars 2006
Messages : 189
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 189
Points : 99
Points : 99
Envoyer un message via MSN à spax
Bien j'ai bien lus les commentaire je te rassure mais justement je ne veut pas afficher l'image je veut juste faire appel a ma fonction : créer et sauvegarder l'image sans que quoique ce soit ne soit afficher .
mais c'est pas ce que j'ai :s

ce que j'ai c'est le fichier qui se créer et le code ASCII qui s'affiche :s aussi malgré que j'ai mis DRAW_RETURN

de plus si j'oublie tout ca et je met un simple :

Code :
1
2
 
	require_once "include/plots/BarPlot.class.php";
dans mon index.php j'ai déja un code ASCII afficher pourtant aucune creation na été demandé et rien n'as été fait que l'include du fichier de la bibliotèque artichow !!!!

merci pour l'aide
spax est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 10h39   #8
Membre régulier
 
Inscription : mars 2006
Messages : 189
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 189
Points : 99
Points : 99
Envoyer un message via MSN à spax
peut éte je me suis mal exprimé mais ce qe je veut c'est avoir sous la main : un script PHP . pret a creer une image a partir des données que je lui transmet mais qui ne fait que creer l'image sur le disque et en aucun cas l'afficher donc en fait je creer des diagram c'est tout et après selon mon choix je les affiche quand je veut . et non pas que a chaque fois j'appel le script pour me créer un diagram il l'affiche a l'ecran . voila :s
spax est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 10h51   #9
Modérateur
 
Avatar de ThomasR
 
Homme Thomas Rambaud
Développeur Web
Inscription : décembre 2007
Messages : 2 140
Détails du profil
Informations personnelles :
Nom : Homme Thomas Rambaud
Âge : 25
Localisation : France

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : décembre 2007
Messages : 2 140
Points : 2 885
Points : 2 885
tu as mis : DRAW_RETURN
En francais ca donne : dessine le retour, on pourrait traduire ca par dessine le retour de la fonction qui est une image. Donc ta fonction retourne l'image dessinée une fois que celle-ci est écrite dans le fichier myFile.

De plus, si tu n'affiches pas l'image et que tu appelles ton script plusieurs fois, tu vas tout le temps écraser myFile.png ? Donc autant appeler une seule fois le script ?
ThomasR est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 10h57   #10
Membre régulier
 
Inscription : mars 2006
Messages : 189
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 189
Points : 99
Points : 99
Envoyer un message via MSN à spax
bien je ne vois que DRAW_RETURN ou DRAW_DISPLAY et les deux affiche le contenu a l'ecran :s comment faire dans ce cas pour que l'image ne soit que creer rien de plus ?

oui je sait que l'image sera ecrasé mais après je pourai spécifier le nom en entrée

merci
spax est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 11h04   #11
Membre régulier
 
Inscription : mars 2006
Messages : 189
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 189
Points : 99
Points : 99
Envoyer un message via MSN à spax
ce que je comprend pas c'est que en utilisant un fichier vierge comme fichier de teste et que je j'appel mon script ou j'ai ecrit
Code :
1
2
 
	file_put_contents($filename, $graph->draw(Graph::DRAW_RETURN));
le fichier png est créer et rien n'est afficher a l'ecran ( en regardant le source c'est totalement vide

et en faissant la même chose mais dans un fichier ou j'ai déja des composante

style : quand j'appuie sur un boutton je céer l'image j'ai le code ASCII qui s'affiche !!! :s
spax est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 11h09   #12
Membre régulier
 
Inscription : mars 2006
Messages : 189
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 189
Points : 99
Points : 99
Envoyer un message via MSN à spax
si je peut étre claire mon but c'est un sevice web que j'appel pour creer mes fichier sans qu'ils me renvoie l'image sur le navigateur
spax est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 11h11   #13
Modérateur
 
Avatar de ThomasR
 
Homme Thomas Rambaud
Développeur Web
Inscription : décembre 2007
Messages : 2 140
Détails du profil
Informations personnelles :
Nom : Homme Thomas Rambaud
Âge : 25
Localisation : France

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : décembre 2007
Messages : 2 140
Points : 2 885
Points : 2 885
Ya pas une doc d'utilisation de ta classe Graph avec les différentes param de retour ?
ThomasR est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 11h16   #14
Membre régulier
 
Inscription : mars 2006
Messages : 189
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 189
Points : 99
Points : 99
Envoyer un message via MSN à spax
si ici :
http://www.artichow.org/doc/Graph#method.draw

Mais sans résultat
spax est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 11h19   #15
Modérateur
 
Avatar de ThomasR
 
Homme Thomas Rambaud
Développeur Web
Inscription : décembre 2007
Messages : 2 140
Détails du profil
Informations personnelles :
Nom : Homme Thomas Rambaud
Âge : 25
Localisation : France

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : décembre 2007
Messages : 2 140
Points : 2 885
Points : 2 885
Ok donc DRAW_RETURN la fonction te retourne l'image DRAW_DISPLAY, elle te l'affiche.
si tu fais $variable = plot(); au lieu de faire plot(); ca devrait marcher.
ThomasR est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 11h27   #16
Membre régulier
 
Inscription : mars 2006
Messages : 189
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 189
Points : 99
Points : 99
Envoyer un message via MSN à spax
déja tester , le simple dans mes fichier de :

Code :
1
2
 
require_once "plots/BarPlot.class.php";
ou

Code :
1
2
 
require_once "plot.php";
affiche déja l'image en ASCII sachant que j'ai rien fait même pas encore appelé ma fonction qui effectue le traitement et creer l'image .
spax est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 12h07   #17
Modérateur
 
Avatar de ThomasR
 
Homme Thomas Rambaud
Développeur Web
Inscription : décembre 2007
Messages : 2 140
Détails du profil
Informations personnelles :
Nom : Homme Thomas Rambaud
Âge : 25
Localisation : France

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : décembre 2007
Messages : 2 140
Points : 2 885
Points : 2 885
Il y a quoi dans : plots/BarPlot.class.php ?
ThomasR est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 12h43   #18
Membre régulier
 
Inscription : mars 2006
Messages : 189
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 189
Points : 99
Points : 99
Envoyer un message via MSN à spax
c'est un fichier de la librairie artichow


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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
 
 
<?php
/*
 * This work is hereby released into the Public Domain.
 * To view a copy of the public domain dedication,
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
 *
 */
 
require_once dirname(__FILE__)."/Plot.class.php";
 
/**
 * BarPlot
 *
 * @package Artichow
 */
class awBarPlot extends awPlot implements awLegendable {
 
	/**
	 * Labels on your bar plot
	 *
	 * @var Label
	 */
	public $label;
 
	/**
	 * Bar plot identifier
	 *
	 * @var int
	 */
	protected $identifier;
 
	/**
	 * Bar plot number
	 *
	 * @var int
	 */
	protected $number;
 
	/**
	 * Bar plot depth
	 *
	 * @var int
	 */
	protected $depth;
 
	/**
	 * For moving bars
	 *
	 * @var int
	 */
	protected $move;
 
	/**
	 * Bars shadow
	 *
	 * @var Shadow
	 */
	public $barShadow;
 
	/**
	 * Bars border
	 *
	 * @var Border
	 */
	public $barBorder;
 
	/**
	 * Bars padding
	 *
	 * @var Side
	 */
	protected $barPadding;
 
	/**
	 * Bars space
	 *
	 * @var int
	 */
	protected $barSpace = 0;
 
	/**
	 * Bars background
	 *
	 * @var Color, Gradient
	 */
	protected $barBackground;
 
	/**
	 * Construct a new awBarPlot
	 *
	 * @param array $values Some numeric values for Y axis
	 * @param int $identifier Plot identifier
	 * @param int $number Bar plot number
	 * @param int $depth Bar plot depth in pixels
	 */
	public function __construct($values, $identifier = 1, $number = 1, $depth = 0) {
 
		parent::__construct();
 
		$this->label = new awLabel;
 
		$this->barPadding = new awSide(0.08, 0.08, 0, 0);
		$this->barShadow = new awShadow(awShadow::RIGHT_TOP);
		$this->barBorder = new awBorder;
 
		$this->setValues($values);
 
		$this->identifier = (int)$identifier;
		$this->number = (int)$number;
		$this->depth = (int)$depth;
 
		$this->move = new awSide;
 
		// Hide vertical grid
		$this->grid->hideVertical(TRUE);
 
	}
 
	/**
	 * Change bars padding
	 * This method is not compatible with awBarPlot::setBarPadding()
	 *
	 * @param float $left Left padding (between 0 and 1)
	 * @param float $right Right padding (between 0 and 1)
	 */
	public function setBarPadding($left = NULL, $right = NULL) {
		$this->barPadding->set($left, $right);
	}
 
	/**
	 * Change bars size
	 * This method is not compatible with awBarPlot::setBarPadding()
	 *
	 * @param int $width Bars size (between 0 and 1)
	 */
	public function setBarSize($size) {
		$padding = (1 - $size) / 2;
		$this->barPadding->set($padding, $padding);
	}
 
	/**
	 * Move bars
	 *
	 * @param int $x
	 * @param int $y
	 */
	public function move($x, $y) {
		$this->move->set($x, NULL, $y, NULL);
	}
 
	/**
	 * Change bars space
	 *
	 * @param int $space Space in pixels
	 */
	public function setBarSpace($space) {
		$this->barSpace = (int)$space;
	}
 
	/**
	 * Change line background color
	 *
	 * @param awColor $color
	 */
	public function setBarColor(awColor $color) {
		$this->barBackground = $color;
	}
 
	/**
	 * Change line background gradient
	 *
	 * @param awGradient $gradient
	 */
	public function setBarGradient(awGradient $gradient) {
		$this->barBackground = $gradient;
	}
 
	/**
	 * Get the line thickness
	 *
	 * @return int
	 */
	public function getLegendLineThickness() {
	}
 
	/**
	 * Get the line type
	 *
	 * @return int
	 */
	public function getLegendLineStyle() {
	}
 
	/**
	 * Get the color of line
	 *
	 * @return Color
	 */
	public function getLegendLineColor() {
	}
 
	/**
	 * Get the background color or gradient of an element of the component
	 *
	 * @return Color, Gradient
	 */
	public function getLegendBackground() {
		return $this->barBackground;
	}
 
	/**
	 * Get a mark object
	 *
	 * @return Mark
	 */
	public function getLegendMark() {
	}
 
	public function drawComponent(awDriver $driver, $x1, $y1, $x2, $y2, $aliasing) {
 
		$count = count($this->datay);
		$max = $this->getRealYMax(NULL);
		$min = $this->getRealYMin(NULL);
 
		// Find zero for bars
		if($this->xAxisZero and $min <= 0 and $max >= 0) {
			$zero = 0;
		} else if($max < 0) {
			$zero = $max;
		} else {
			$zero = $min;
		}
 
		// Get base position
		$zero = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint(0, $zero));
 
		// Distance between two values on the graph
		$distance = $this->xAxis->getDistance(0, 1);
 
		// Compute paddings
		$leftPadding = $this->barPadding->left * $distance;
		$rightPadding = $this->barPadding->right * $distance;
 
		$padding = $leftPadding + $rightPadding;
		$space = $this->barSpace * ($this->number - 1);
 
		$barSize = ($distance - $padding - $space) / $this->number;
		$barPosition = $leftPadding + $barSize * ($this->identifier - 1);
 
		for($key = 0; $key < $count; $key++) {
 
			$value = $this->datay[$key];
 
			if($value !== NULL) {
 
				$position = awAxis::toPosition(
					$this->xAxis,
					$this->yAxis,
					new awPoint($key, $value)
				);
 
				$barStart = $barPosition + ($this->identifier - 1) * $this->barSpace + $position->x;
				$barStop = $barStart + $barSize;
 
				$t1 = min($zero->y, $position->y);
				$t2 = max($zero->y, $position->y);
 
				if(round($t2 - $t1) == 0) {
					continue;
				}
 
				$p1 = new awPoint(
					round($barStart) + $this->depth + $this->move->left,
					round($t1) - $this->depth + $this->move->top
				);
 
				$p2 = new awPoint(
					round($barStop) + $this->depth + $this->move->left,
					round($t2) - $this->depth + $this->move->top
				);
 
				$this->drawBar($driver, $p1, $p2);
 
			}
 
		}
 
		// Draw labels
		foreach($this->datay as $key => $value) {
 
			if($value !== NULL) {
 
				$position = awAxis::toPosition(
					$this->xAxis,
					$this->yAxis,
					new awPoint($key, $value)
				);
 
				$point = new awPoint(
					$barPosition + ($this->identifier - 1) * $this->barSpace + $position->x + $barSize / 2 + 1 + $this->depth,
					$position->y - $this->depth
				);
 
				$this->label->draw($driver, $point, $key);
 
			}
 
		}
 
	}
 
	public function getXAxisNumber() {
		return count($this->datay) + 1;
	}
	// ça bidouille à fond ici !
	public function getXMax() {
		return array_max($this->datax) + 1;
	}
 
	public function getXCenter() {
		return TRUE;
	}
 
	protected function drawBar(awDriver $driver, awPoint $p1, awPoint $p2) {
 
		// Draw shadow
		$this->barShadow->draw(
			$driver,
			$p1,
			$p2,
			awShadow::OUT
		);
 
		if(abs($p2->y - $p1->y) > 1) {
 
			$this->barBorder->rectangle(
				$driver,
				$p1,
				$p2
			);
 
			if($this->barBackground !== NULL) {
 
				$size = $this->barBorder->visible() ? 1 : 0;
 
				$b1 = $p1->move($size, $size);
				$b2 = $p2->move(-1 * $size, -1 * $size);
 
				// Draw background
				$driver->filledRectangle(
					$this->barBackground,
					new awLine($b1, $b2)
				);
 
			}
 
		}
	}
 
}
 
registerClass('BarPlot');
?>
spax est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/09/2008, 14h03   #19
Membre régulier
 
Inscription : mars 2006
Messages : 189
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 189
Points : 99
Points : 99
Envoyer un message via MSN à spax
Bon vu que j'ai passer plus de 2 jours dessus j'ai opter pour une solution qui me parait plus simple et m'evite d'eplucher tout les code .

Javascript qui execute le script de la construction de l'image et la j'ai la creation de l'image puis je la manipule comme je veut .
spax 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 06h14.


 
 
 
 
Partenaires

Hébergement Web