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

Bug #4333 Legend division by zero error on PieChart
Submitted: 2005-05-12 08:24 UTC
From: attb2 at fw dot hu Assigned: nosey
Status: Closed Package: Image_Graph
PHP Version: 4.3.10 OS: Debian Sarge
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 33 - 21 = ?

 
 [2005-05-12 08:24 UTC] attb2 at fw dot hu
Description: ------------ If I want to display a Legend from a PieChart Image_Graph throws a "division by zero" error. I traced down this error: /Graph/Plot.php function _legendSample($x, $y, &$font) { Line: 719 [...] $point = $this->_getMarkerData($point, $nextPoint, $prevPoint, $i); [...] } In this method calling '$i' variable has no value! (Not initialized.) Example is below. (Example is assembled from tutorial and GraphPite site informations.) Thanks Attila Szuts Reproduce code: --------------- <?php require_once("Image/Graph.php"); // ----------------------------------------------------------------------------- $startdate = date('Y-m-01'); $enddate = date('Y-m-d'); $month = date('Y-m'); $total_income = 541; // Income $total_outcome = 19; // Outcome // ----------------------------------------------------------------------------- // Graph. $Graph =& new Image_Graph(400, 300); // Font. $Arial =& $Graph->addFont(new Image_Graph_Font_TTF("arial.ttf")); $Arial->setSize(11); // Cimke font $ArialSolid =& $Graph->addFont(new Image_Graph_Font_TTF("arial.ttf")); $ArialSolid->setSize(10); $Graph->add( new Image_Graph_Layout_Vertical( new Image_Graph_Layout_Vertical( new Image_Graph_Title(sprintf("Income / Outcome %s (Ft)", $month), $Arial), $PlotArea = new Image_Graph_Plotarea(), 5 ), $Legend = new Image_Graph_Legend(), // Legend 70 ) ); $Graph->hideLogo(); $PlotArea->hideAxis(); // Legend $Legend->setPlotArea($PlotArea); //$Legend->setFillColor(IMAGE_GRAPH_WHITE); //$Legend->setFont($ArialSolid); // Adatok. //$DataSet =& new Image_Graph_Dataset_Random(10, 2, 15, true); $DataSet =& new Image_Graph_Dataset_Trivial(); $DataSet->addPoint('Income', $total_income); $DataSet->addPoint('Outcome', $total_outcome); $Plot =& $PlotArea->addPlot(new Image_Graph_Plot_Pie($DataSet)); // create a X data value marker $Marker =& $Plot->add(new Image_Graph_Marker_Value(IMAGE_GRAPH_VALUE_X)); $Marker->setFont($ArialSolid); // fill it with white $Marker->setFillColor(IMAGE_GRAPH_WHITE); // and use black border $Marker->setBorderColor(IMAGE_GRAPH_BLACK); // create a pin-point marker type $PointingMarker =& $Plot->add(new Image_Graph_Marker_Pointing_Angular(30, $Marker)); // and use the marker on the plot $Plot->setMarker($PointingMarker); $Plot->Radius = 2; $Plot->setLineColor(IMAGE_GRAPH_GRAY); $GREEN =& $Graph->newColor(IMAGE_GRAPH_GREEN, 100); $RED =& $Graph->newColor(IMAGE_GRAPH_RED, 100); $FillArray =& new Image_Graph_Fill_Array(); $Plot->setFillStyle($FillArray); $FillArray->add($GREEN); $FillArray->add($RED); $Graph->done(); // ----------------------------------------------------------------------------- ?> Expected result: ---------------- A nice Piechart with Legends. If you comment out the $Legend->setPlotArea($PlotArea); line a piechart will be displayed. (without Legend) Actual result: -------------- Warning: Division by zero in /mnt/work/lotimex/web/Graphs/Image/Graph/Plot/Pie.php on line 63

Comments

 [2005-05-17 21:15 UTC] pear dot nosey at veggerby dot dk
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.