problème afficher graphique JpGraph

itachi371
Invité n'ayant pas de compte PHPfrance

03 nov. 2008, 10:08

Bonjour à tous,

J'utilise la librairie JpGraph pour afficher des graphiques à partir d'une BD.
Le graphique se génère bien avec les infos souhaitées. Problème, il ne s'affiche pas dans le navigateur.
J'ai ce message :

L'image “http://serveur_de_test/script.php” ne peut être affichée car elle contient des erreurs.

J'y comprends rien ! J'utilise JpGraph dans d'autres application sur le même serveur et je n'ai aucun problème pour afficher les graphes ! En plus l'image se créé...

Auriez-vous une idée ?

Je vous mets mon script juste en dessous :

Code : Tout sélectionner

<?php session_start(); /* On vérifie si une personne est connecté et est passe par le portail */ require ("../conf/config.php"); require ("../conf/define.inc.php"); if ($_GET['def_mois'] == ""){ $def_mois = date("n"); }else{ $def_mois = $_GET['def_mois']; } if ($_GET['def_annee'] == ""){ $def_annee = date("Y"); }else{ $def_annee = $_GET['def_annee']; } /* Requete pour lister les lots */ $requete_listing = "select count(*) as Nbdemande,agent.agents.nom_agent from demandes left outer join agent.agents on agents.nom_matricule=demandes.techN2 where YEAR(date_statistique)='$def_annee' and demandes.id_etat='3' group by agent.agents.nom_agent"; $result_listing = mysql_query($requete_listing) or die('Erreur SQL !'. "ATTENTION" .'<br>'.mysql_error()); //Si on a paramétrer la taille de l'image à afficher if (($_GET['haut'] <> '') && ($_GET['larg'] <> '')){ $hauteur = $_GET['haut']; $largeur = $_GET['larg']; }else{ $hauteur = 650; $largeur = 1000; } $nbrow = mysql_num_rows($result_listing); //nombre d'enregistrement que renvoi la requete select while ($row_demande=mysql_fetch_array($result_listing)){ if (trim($row_demande['nom_agent']) != '' && trim($row_demande['nom_agent']) != 'Null'){ $tab_legend[] .= $row_demande['nom_agent']; $tab_data[] .= $row_demande['Nbdemande']; } } //Ajout bibliothèque artichow //require_once "../func/jpgraph/BarPlot.class.php"; include ("../func/jpgraph/jpgraph.php"); include ("../func/jpgraph/jpgraph_bar.php"); // Create the graph. These two calls are always required $graph = new Graph($largeur,$hauteur,"auto"); $graph->SetScale("textlin"); $graph->yaxis->scale->SetGrace(10); // Add a drop shadow $graph->SetShadow(); // Setup the legend box colors and font $graph->legend->SetColor('#C5453B','navy'); $graph->legend->SetFillColor('#F7FEED'); $graph->legend->SetFont(FF_ARIAL,FS_BOLD,8); $graph->legend->SetShadow('[email protected]',3); $graph->legend->SetPos(0.05,0.05,'right','top'); // Adjust the margin a bit to make more room for titles $graph->img->SetMargin(50,30,30,100); $graph->img->SetColor ("[email protected]"); $graph->SetMarginColor('#FDF9EF'); // Create a bar pot $bplot = new BarPlot($tab_data); // Adjust fill color $bplot->SetFillColor('#FFB879'); $bplot->value->Show(); $bplot->SetLegend('Nombre de statistique'); $bplot->value->SetFont(FF_ARIAL,FS_BOLD,10); $bplot->value->SetAngle(45); $bplot->value->SetColor("#C5453B"); $bplot->value->SetFormat('%d'); $graph->Add($bplot); // Setup the titles $graph->title->Set("Total des statistiques traités par attributaire en". $def_annee); $graph->title->SetFont(FF_FONT1,FS_BOLD,12); $graph->title->SetColor("#256A95"); $graph->xaxis->title->Set("Demandeurs"); $graph->xaxis->SetTickLabels($tab_legend); $graph->xaxis->title->SetColor("#E97F18"); $graph->xaxis->SetColor("#8BB05B"); $graph->xaxis->SetLabelAngle(90); $graph->yaxis->title->Set("Nombre de statistique"); $graph->yaxis->title->SetColor("#E97F18"); $graph->ygrid->SetFill(true,'#[email protected]','#[email protected]'); $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); //On ajoute les information de lorigine des stats $txt=new Text("Source : Application Demande Statistique V " . $appversion . " - Graphique généré le " . date("d/m/Y") . " par $_SESSION[prenomagents] $_SESSION[nomagents] "); $txt->SetPos(20,$hauteur-25); $txt->SetFont(FF_FONT1,8); $txt->SetColor("#256A95"); $graph->AddText($txt); // Display the graph $graph->Stroke(); $img="graph_agent.png"; $graph->stroke($img) ?>
Toutes les infos que je souhaitent afficher sont bien récupérés. J'ai testé mon code sans l'appel à JpGraph.

Merci de votre aide.

@+ tard

Itachi371
Invité n'ayant pas de compte PHPfrance

03 nov. 2008, 15:59

C'est bon j'ai touvé.

Dans mon fichier, j'appelais un fichier de configuration. Ce fichier devait être "vérolé car en le remplaçant par un fichier similaire (j'ai juste changé les paramètres d'accès à la base) ça fonctionne sans problème !

@+

dami
Invité n'ayant pas de compte PHPfrance

12 juin 2009, 15:17

Bonjour, j'ai eu le meme probléme que toi, tu peux me montrer stp comment tas fait, Merci d avance