Re: Image_Graph
| From: | hugo | Date: | Sun, 10 Apr 2005 18:27:31 +0000 |
| Subject: | Re: Image_Graph | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18672@lists.php.net to get a copy of this message | ||
In fact, I prefer to take an example because I think my explanations was not
very clear :
http://caro208.free.fr/DjihadCompteur/pict/repartitionUser1A1.png
As you can see in this pict, there is several bars and each value in Y-Axis
is a integer number.
But I don't understant why, the bar often take the value half above its real
value. (the real value is 4, the value on the graph is 4.5 etc...)
I used this code :
($attaques is an array of value)
You can notice that I use forceMaximum for Y-axis.
// create the dataset
$Dataset =& Image_Graph::factory('dataset');
foreach ($attaques as $attaque)
{
$empire = substr ( $attaque['allianceempire'],0,15);
$Dataset->addPoint($empire,$attaque['totattaque'] );
}
$GridY =& $Plotarea->addNew('bar_grid', null, IMAGE_GRAPH_AXIS_Y);
$GridY->setFillStyle(Image_Graph::factory('gradient',
array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey')));
// create the plot as bar chart using the dataset
$Plot =& $Plotarea->addNew('bar', array(&$Dataset, 'normal',
'nombre
d\'attaque'));
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
$Plot->setFillStyle($FillArray);
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'green',
'white'));
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'blue',
'white'));
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL,
'yellow', 'white'));
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'red',
'white'));
$FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL,
'orange', 'white'));
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocess
or_Formatted', '%0.0f'));
$max = $attaques[0]['totattaque'];
$AxisY->forceMaximum($max);
// output the Graph dans un fichier png
$Graph->done(array('filename' => "$filename"));
----- Original Message -----
From: "Jesper Veggerby Hansen" <pear.nosey@veggerby.dk>
To: "hugo" <hugo123fr@hotmail.com>
Cc: "PEAR general list" <pear-general@lists.php.net>
Sent: Sunday, April 10, 2005 6:00 PM
Subject: Re: [PEAR] Image_Graph
> It has something to do with the way the axis calculates the intervals
> (IIRC). If you don't like/want the "suggested" maximum simply use the
> forceMaximum() on the axis, then you can supply any value you want.
>
> regards
> Jesper
>
> hugo wrote:
> > Hi, I have a problem when using image_graph.The maximum in Y Axis is
> > incorrect in regard of the data I have.
> > I print_r the dataset :
> >
> > image_graph_dataset_trivial Object ( [_data] => Array ( [0] => Array (
[X]
> > => nameTest [Y] => 4 [ID] => ) ) [_posX] => 0 [_minimumX] => nameTest
> > [_maximumX] => 1 [_minimumY] => 4 [_maximumY] => 4 [_count] => 1 [_name]
> > => )
> >
> > As you can see, the maximum is 4 in Y. I draw a bar chart but the the
bar
> > goes to 4.5.
> > Any idea about this gap ?
> >
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>