ParMesSoins | Bonjour,
j'ai un souci avec un script qui génère un graphique via JPgraph
Ce script fonctionne, mais il affiche seulement la dernière ligne de valeurs,
alors que chaque ligne est créé dans la boucle voici le script :
Code :
- <?php
- include ('jpgraph/src/jpgraph.php');
- include ('jpgraph/src/jpgraph_line.php');
- // Callback to negate the argument
- function _cb_negate($aVal) {
- return round(-$aVal);
- }
- //taille de l'image
- $sql_width = 'SELECT max(id) FROM `prono_historique`';
- $Valide_width = mysql_query($sql_width, $Connexion) or die ("Requète <b><i>".$sql_width."</i></b> invalide" );
-
- //Recuperation des resultats
- while ($val_width=mysql_fetch_row($Valide_width))
- {
- $width = 60 * ($val_width[0]);
- }
- $color_line_RGB = Array(
- "#FF0033","#993366","#CC00CC","#9900FF","#330066","#009999",
- "#00CC00","#000000","#999900","#FF9900","#FF3333","#999999","#666666","#999966" );
- // Setup the graph
- $graph = new Graph($width,480);
- $graph->SetMarginColor('#CCCCFF');
- $graph->SetScale("textlin" );
- $graph->SetFrame(false);
- $graph->SetMargin(50,50,30,30);
- $graph->tabtitle->Set('Statistiques des Joueurs :' );
- $graph->tabtitle->SetWidth(TABTITLE_WIDTHFIT);
- $graph->tabtitle->SetColor('black','#EFEFFF','#CCCCFF');
- $graph->ygrid->SetFill(true,'#EFEFFF','#fdfdff');
- $graph->ygrid->SetColor('#CCCCFF');
- $graph->xgrid->SetColor('#CCCCFF');
- $graph->xgrid->Show();
- // les données ...
- $sql_id = "SELECT id, nom
- FROM `prono_historique`
- GROUP BY nom
- ORDER BY `classement` ASC";
- $Valide_id = mysql_query($sql_id, $Connexion) or die ("Requète <b><i>".$sql_id."</i></b> invalide" );
- $tab_month = array(1=>"Jan", "Fev", "Mar", "Avr", "Mai", "Juin", "Juil", "Aou", "Sep", "Oct", "Nov", "Dec" );
- $comb=1;
- //Recuperation des resultats
- while ($val_ID=mysql_fetch_row($Valide_id))
- {
- $id = $val_ID[0];
- $nom = $val_ID[1];
- $val_pts = array(); //remet le tableau a zero
- $sql_pts = 'SELECT id, nom, classement, date FROM `prono_historique` WHERE nom="'.$nom.'" ORDER BY `id` ASC';
- $Valide_pts = mysql_query($sql_pts, $Connexion) or die ("Requète <b><i>".$sql_pts."</i></b> invalide" );
-
- $date_maj = array();
- //Recuperation des resultats
- while ($array_pts=mysql_fetch_array($Valide_pts))
- {
- $val_pts[]="-".$array_pts["classement"];
- // if(!isset($date_aff)) {
- $tab_dmy = explode('-', $array_pts[3]);
- $day = date("w", mktime(0, 0, 0, $tab_dmy[1], $tab_dmy[2], $tab_dmy[0]));
- $date_aff = $tab_dmy[2]." ";
- settype($tab_dmy[1], "int" );
- $date_aff .= $tab_month[$tab_dmy[1]];
-
- $date_maj[]=$date_aff;
- // }
- }
- // Creation de la ligne
- $line = new LinePlot($val_pts);
- $lacouleurdeLigne = array_rand ($color_line_RGB, 2);
- $lacouleur = $color_line_RGB[$lacouleurdeLigne[0]];
- $line->SetColor($lacouleur);
- $line->SetLegend($nom);
- // $line->SetLegend("#000000" );
- $line->SetWeight(1);
- $line->value->Show(true);
- $line->value->SetFormat($nom);
- $line->value->SetMargin(-15);
- $line->SetFillFromYMin();
- $graph->Add($line);
- $comb++;
- }
- //legend des X
- $graph->xaxis->SetTickLabels($date_maj);
- $graph->xaxis->SetLabelSide(SIDE_DOWN);
- $graph->xaxis->SetPos('min');
- $graph->xaxis->SetColor('#CCCCFF', '#DD8000');
- //les axes Y
- //$graph->yaxis->title->Set("Places", "low" );
- $graph->yaxis->HideZeroLabel();
- $graph->yaxis->SetLabelMargin(25);
- $graph->yaxis->SetLabelFormatCallback("_cb_negate" ); //supprime les -
- $graph->yaxis->SetColor('#CCCCFF', '#DD8000');
- //$graph->yaxis->Hide();
- //pas de legend
- $graph->legend->Hide();
- // Output line
- $graph->Stroke("stats_prono.png" );
- ?>
- <img src="stats_prono.png" border="0">
- <br />
- <?PHP
- echo $comb;
- ?>
|
Message édité par ParMesSoins le 19-09-2007 à 16:47:32
|