Re: Image_Graph
| From: | Jesper Veggerby Hansen | Date: | Wed, 14 Sep 2005 21:07:58 +0000 |
| Subject: | Re: Image_Graph | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20967@lists.php.net to get a copy of this message | ||
Hi James,
Yes you are right this won't work the way you do it, but the good news is that it is possible (you are trying to accomplish something like what is being done in the test tests/axis/category.php).
The reason you don't get any output is because the y-axis by default is a linear scaled numerical axis (whereas the x-axis is a "category" axis - use values as-they-are, no scaling). This type of axis is what you need for your y-axis as well. To accomplish this, simply state in the constructor of the plotarea what type of axis you wish, i.e.
...
$Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis_Category', 'Image_Graph_Axis_Category'),
...
Should get you what you want!
best regards
Jesper Veggerby
Kilbride, James wrote:
I am attempting to use Image_Graph to display a cross reference 'table'
as it were. Essentially I have a set of points where the x and y axis
are character strings. Point1 = ('Open Source','Apache'), Point2 =
('Open Source', 'Pear'), Point3 =('Proprietary', 'Microsoft').. etc. I
want to use Image_Graph_Plot_Dot to display the data with points in the
cross spots. Is this possible?(Yes i know I can do something like this
with html, I want to know if I can do it with Image_Graph). Currently
when I try to use character points for both x and y I don't get the y
axis being set correctly.
Here's the basic code I wrote:
$Graph =& Image_Graph::factory('graph', array(400, 300)); $Graph->add( Image_Graph::vertical( Image_Graph::factory('title', array('Data/Activity Cross
Reference Chart', 12)), Image_Graph::vertical( $Plotarea = Image_Graph::factory('plotarea'), $Legend = Image_Graph::factory('legend'), 90 ), 5 ) ); $Legend->setPlotarea($Plotarea);
// create the dataset $Dataset =& Image_Graph::factory('dataset'); //Populate Dataset
$Dataset->addPoint('Apache','Open Source');
$Dataset->addPoint('Pear','Open Source');
$Dataset->addPoint('Microsoft','Proprietary');
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Dot', array(&$Dataset)); $Marker =& Image_Graph::factory('Image_Graph_Marker_Cross'); $Marker->setFillColor('blue'); $Marker->setLineColor('black'); // set a line color $Plot->setMarker($Marker); $Plot->setTitle('Data');
$Graph->done();
Is this something that shouldn't work? Or should it and it's a bug I
need to report?
James Kilbride