JP Graph : Axe des Y dans le sens décroissant !

cs_prim Messages postés 12 Date d'inscription mardi 17 juin 2003 Statut Membre Dernière intervention 23 mars 2009 - 15 août 2005 à 13:07
Evangun Messages postés 1980 Date d'inscription dimanche 20 février 2005 Statut Membre Dernière intervention 24 septembre 2012 - 15 août 2005 à 13:53
Salut tout le monde !

Bon voilà j'ai un petit problème avec JPGraph...
Je veux juste créer un graphe sous forme de ligne qui représente l'évolution d'un classement d'un joueur qui va du numéro 1 à un numéro X.
Voici ce que j'ai fait :
http://legroupedcachan.free.fr/evolution.php?joueur=Prim
Mais le seul problème c'est que la valeur du classement est négatif puisque j'ai inversé le graphe pour l'avoir dans le sens décroissant...

Si quelqu'un a compris mon problème et qu'il peut m'aider ça serait sympa

Voici mon code :

<?php
include ("outils/jpgraph/source/jpgraph.php");
include ("outils/jpgraph/source/jpgraph_line.php");
include ("outils/jpgraph/source/jpgraph_error.php");
require_once("connexion_base.php");


// Callback to negate the argument
function _cb_negate($aVal) {
return round(-$aVal);
}


//fonction d'affichage du graphe pour l'évolution d'UN joueur
function evolution()
{
$joueur=$_GET["joueur"];
$titre="Evolution du classement de ".$joueur;


$datay[]=new array(267,163);
$datax[]=new array("06/12/2003","07/12/2003");


// Negate all data
$n = count($datay);
for($i=0; $i<$n; ++$i)
{
$datay[$i] = round(-$datay[$i]);
}

$graph = new Graph($largeur,400,"auto");
$graph->img->SetMargin(40,40,40,40);
$graph->img->SetAntiAliasing();



$graph->SetScale("textlin");
$graph->SetShadow();
$graph->title->Set($titre);
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetTickLabels($datax);
// Use 20% "grace" to get slightly larger scale then min/max of data
$graph->yscale->SetGrace(20);

$graph->yaxis->SetLabelFormatCallback("_cb_negate");


$p1 = new LinePlot($datay);
$p1->mark->SetType(MARK_FILLEDCIRCLE);
$p1->mark->SetFillColor("red");
$p1->mark->SetWidth(4);
$p1->value->show();
$p1->SetColor("blue");
$p1->SetCenter();
$graph->Add($p1);


$graph->Stroke();
}


evolution();


?>
A voir également:

1 réponse

Evangun Messages postés 1980 Date d'inscription dimanche 20 février 2005 Statut Membre Dernière intervention 24 septembre 2012 4
15 août 2005 à 13:53
bonjour!

moi je n'ai pas compris en fait. qu'est-ce qui ne va pas sur le graphe que tu as déjà fait?

et ce que tu veux, c'est que l'origine des ordonnées soit 300, c'est ça?
0
Rejoignez-nous