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 08/04/2007, 18h41   #1
Nouveau Membre du Club
 
Inscription : février 2007
Messages : 219
Détails du profil
Informations forums :
Inscription : février 2007
Messages : 219
Points : 32
Points : 32
Par défaut [JpGraph] message d'erreur: HTTP headers have already been sent

Bonjour,
J'ai le messsage suivant qui s'affiche lorsque j'execute ma page:
JpGraph Error: HTTP headers have already been sent.
Caused by output from file jpgraph.php at line 8.
Comment faire??

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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?include("inc/conf.inc");?>
<?
$ww = 28;
$tvar = array('NB','nb','NJ','nj','PB','pb','PJ','pj');
?>
<table width=* border=1 cellspacing=0 cellpadding=5>
<tr align=center valign=center>
  <td><strong>Semaine <?=$ww;?></td>
<?
$sql = "SELECT * FROM regions ORDER BY regions_nom;";
$result = mysql_query($sql);
$cptreg = 0;
while ($rs = mysql_fetch_array($result)) {
  $cptreg++;
  $regions_nom = $rs['regions_nom'];
  $treg[$cptreg] = $rs['regions_id'];
  $tzone[$cptreg] = 0;
?>
  <td><strong><?=$regions_nom;?></strong></td>
<?
}
?>
  <td><strong>Total</strong></td>
</tr>
<? for ($n=1;$n<=4;$n++) { ?>
<tr align=center>
  <td><strong><?=$tvar[($n-1)*2];?></strong></td>
<?
$result = mysql_query($sql);
$m = 0;
$totalvar = 0;
while ($rs = mysql_fetch_array($result)) {
  $m++;
  $tmp = "prev_".$tvar[($n*2)-1]."_ton";
  $o = $treg[$m];
  $sql2 = "SELECT SUM($tmp) AS nbre FROM prev, operateurs WHERE prev.operateurs_id = operateurs.operateurs_id AND regions_id = $o AND prev_ss = $ww;";
  $result2 = mysql_query($sql2);
  $rs2 = mysql_fetch_array($result2);
  $nbre = $rs2['nbre']*1;
  $tableau[$n][$m]=$nbre;
  $tzone[$m] = $tzone[$m] + $nbre;
  $totalvar = $totalvar + $nbre;
$x = array($nbre);
  echo("<td>$nbre</td>");
?>
<? } ?>
  <td><strong><?=$totalvar;?></strong></td>
</tr>
<? } ?>
 
<tr align=center>
  <td><strong>TOTAL</strong></td>
<?
$total = 0;
for ($k=1;$k<=$cptreg;$k++) {
  $total = $total+$tzone[$k];
?>
  <td><strong><?=$tzone[$k];?></strong></td>
<? } ?>
  <td><strong><?=$total;?></strong></td>
</tr>
</table>
 
<?php
include ("jpgraph-1.21b/src/jpgraph.php");
include ("jpgraph-1.21b/src/jpgraph_bar.php");
setlocale (LC_ALL, 'et_EE.ISO-8859-1');
 
$data1y=array(1237,710,470);
$data2y=array(2060,1031,585);
$data3y=array(1186,514,440);
$data4y=array(622,877,475);
 
// Create the graph. These two calls are always required
$graph = new Graph(500,400,"auto");    
$graph->SetScale("textlin");
 
$graph->SetShadow();
$graph->img->SetMargin(60,50,40,60);
 
 
// Create the bar plots
$b1plot = new BarPlot($data1y);
$b1plot->SetPattern(BAND_RDIAG,"white");
$b1plot->SetLegend("NB");
$b1plot->SetFillColor("orange");
$b2plot = new BarPlot($data2y);
$b2plot->SetFillColor("orange");
$b2plot->SetLegend("NJ");
$b3plot = new BarPlot($data3y);
$b3plot->SetFillGradient('white','green',GRAD_CENTER);
$b3plot->SetLegend("PB");
$b4plot = new BarPlot($data4y);
$b4plot->SetFillColor("green");
$b4plot->SetLegend("PJ");
 
$graph->SetBackgroundGradient('#9999FF','white',GRAD_HOR,BGRAD_MARGIN);
 
$graph->legend->Pos(0.03,0.5,"right","center");
$graph->legend->SetFont(FF_FONT1,FS_BOLD);
 
// Create the grouped bar plot
$gbplot = new AccBarPlot(array($b1plot,$b2plot,$b3plot,$b4plot));
$lbl = array("Roussillon","Gard-Crau","Vallée Rhône");
$graph->xaxis->SetTickLabels($lbl);
 
// ...and add it to the graPH
$graph->Add($gbplot);
 
$graph->title->Set("Prévisions apports S28 par région
");
$graph->xaxis->title->Set("Régions");
$graph->yaxis->title->Set("Tonnes");
 
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
 
// Display the graph
$graph->Stroke();
?>
coco38 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/04/2007, 19h38   #2
Membre expérimenté
 
Développeur Web
Inscription : avril 2006
Messages : 430
Détails du profil
Informations personnelles :
Localisation : Belgique

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : avril 2006
Messages : 430
Points : 538
Points : 538
la raison est que jpgraph fait de l'ouput de headers pour déclarer la sortie du graphique en tant qu'image... Tu ne peux donc mettre la sortie du graphique dans le flux normal de ta page. Tu dois pas contre faire un script php séparé, qui s'occupe de faire le graphique (et uniquement le graphique), et inclure l'appel vers ce script, via un tag <img> dans ta page principale.

En admettant que tu fasses un script "graph.php" (qui ne contient que le code jpgraph), tu aurais donc dans ton html
Code :
1
2
3
4
5
6
 
  ...
  <td><strong><?=$total;?></strong></td>
</tr>
</table>
<img src="graph.php" />
et dans graph.php, tout le reste.
__________________
Merci à Microsoft pour avoir transformé un métier relativement terne et basé sur une approche bêtement technique et rigoureuse des faits, en challenge quotidien, nécessitant une remise en question permanente à l'échelle du quart d'heure
bkill est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/04/2007, 19h57   #3
Nouveau Membre du Club
 
Inscription : février 2007
Messages : 219
Détails du profil
Informations forums :
Inscription : février 2007
Messages : 219
Points : 32
Points : 32
mon problème c'est que si je fais ça ça ne marche pas car j'utilise un tableau que j'ai créer dans une boucle et donc après il me met que une variable non définie.
coco38 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/04/2007, 00h03   #4
Membre expérimenté
 
Développeur Web
Inscription : avril 2006
Messages : 430
Détails du profil
Informations personnelles :
Localisation : Belgique

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : avril 2006
Messages : 430
Points : 538
Points : 538
et bien rajoute dans le script qui génère le graphique tout le code nécessaire à jpgraph pour qu'il puisse te faire ca sans erreurs...
__________________
Merci à Microsoft pour avoir transformé un métier relativement terne et basé sur une approche bêtement technique et rigoureuse des faits, en challenge quotidien, nécessitant une remise en question permanente à l'échelle du quart d'heure
bkill est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/04/2007, 10h03   #5
Nouveau Membre du Club
 
Inscription : février 2007
Messages : 219
Détails du profil
Informations forums :
Inscription : février 2007
Messages : 219
Points : 32
Points : 32
Non mais j'utilise un tableau qui est dans l'autre fichier mais je sais pas comment faire pour aller prendre les valeurs de ce tableau dans l'autre fichier. Sinon j'ai réussi en créant une image mais je ne veux pas générer d'image.
coco38 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 21h41.


 
 
 
 
Partenaires

Hébergement Web