Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.8.0

Bug #2831 using Image_Graph_Fill in Image_Graph_Fill_Array
Submitted: 2004-11-25 22:46 UTC
From: oliver at burtchen dot com Assigned:
Status: Wont fix Package: Image_Graph
PHP Version: 5.0.2 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2004-11-25 22:46 UTC] oliver at burtchen dot com
Description: ------------ Using Image_Graph-0.3.0dev2-pre: There is a problem when using 'Image_Graph_Fill' in an 'Image_Graph_Fill_Array'. First of all, method &add(&$style, $id = '') in Image_Graph_Fill_Array should return $style, but has no return-value. With this bug fixed, if you then use $style->setFillColor(), it will not be painted. If you use setBackgroundColor(), the plotarea ist painted with this color, not only the datapoint. Reproduce code: --------------- include_once('Image/Graph.php'); $graph =& Image_Graph::factory('graph', array(640, 400)); $graph->add($plotarea = Image_Graph::factory('plotarea')); $dataset =& Image_Graph::factory('Dataset_Sequential', array(array('1' => 10, '2' => 20, '3' => 10))); $plot =& $plotarea->addNew('bar', array($dataset, 'bar')); $fill =& Image_Graph::factory('Image_Graph_Fill_Array'); $fill->addColor('#ff0000', '1'); $fill_green =& $fill->addNew('Image_Graph_Fill', null, '2'); // what is the right one to use ???? $fill_green->setFillColor('#00ff00'); $fill_green->setBackgroundColor('#00ff00'); $fill->addNew('Image_Graph_Fill_Gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, '#ff0000', '#ff0000'), '3'); $plot->setFillStyle(&$fill); $graph->done(); Expected result: ---------------- Should paint three red bars.

Comments

 [2004-11-25 22:55 UTC] oliver at burtchen dot com
The example should return two red bars, and a green one. ;-)
 [2004-11-26 07:32 UTC] pear dot nosey at veggerby dot dk
You shouldn't use either: Image_Graph_Fill is an abstract class :) (http://pear.php.net/package/Image_Graph/docs/0.3.0dev1/apidoc/Image_Graph-0.3.0dev1/Image_Graph_Fill.html) However you do have a point, but it's more of a design issue! In previous versions the fill style was dependent upon coordinates and the 'easy' way to do this was to make the fillstyles inherited from Image_Graph_Element (but you could (rightly) argue that this is an apparent discrepancy with design - a fill is not really an element you put on the canvas). But this being history, because the fill's are now actually calculated by the driver when doing the actual fill (it has coordinates there of couse), this inheritance should be removed. Solid colored fillings can only (and *should* only be done using addColor() - mainly due to performance). But thanks a lot for your findings. Also a little note in your usage of Image_Graph_Dataset_Sequential: the keys in your associated array are not used, it only uses the datavalues, i.e. 10, 20 and 10. But maybe it could be an idea to allow Image_Graph_Dataset_Trivial to get an array as parameter to the constructor with the associated data array instead of having to do ->addPoint(), ->addPoint()...