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

Bug #7423 No bar for datasets with single value
Submitted: 2006-04-19 14:47 UTC
From: christoffer at natlikan dot se Assigned:
Status: No Feedback Package: Image_Graph (version 0.7.2)
PHP Version: 5.1.1 OS: Linux 2.4.21
Roadmaps: (Not assigned)    
Subscription  


 [2006-04-19 14:47 UTC] christoffer at natlikan dot se (Christoffer Lund)
Description: ------------ When you have datasets with only one value no bar will show upp. I know it's kind of silly to have a graph with only one bar... but it's not my call. I've been trying to fix it and think I've come up with a solution. By changing the lines 705-707 in Axis.php from: if ($this->_axisValueSpan == 0) { $this->_delta = false; } elseif ($this->_type == IMAGE_GRAPH_AXIS_X) { to: /* if ($this->_axisValueSpan == 0) { $this->_delta = false; } elseif ($this->_type == IMAGE_GRAPH_AXIS_X) { */ if ($this->_type == IMAGE_GRAPH_AXIS_X) { In other words, by removing the first if-satement. Test script: --------------- <?php require_once 'Image/Graph.php'; // Create the graph $Graph =& Image_Graph::factory('graph', array(400, 300)); // Add a TrueType font $Font =& $Graph->addNew('font', 'Verdana'); // Set the font size to 11 pixels $Font->setSize(8); $Graph->setFont($Font); $Graph->add( Image_Graph::vertical( Image_Graph::factory('title', array('Bar Chart Sample', 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('random', array(1, 2, 15, false)); // Create the 1st plot as smoothed area chart using the 1st dataset $Plot =& $Plotarea->addNew('bar', array(&$Dataset)); // Set a line color $Plot->setLineColor('gray'); // Set a standard fill style $Plot->setFillColor('blue@0.2'); // Output the Graph $Graph->done(); ?> Expected result: ---------------- A graph with one centered bar. Actual result: -------------- A graph with no bar at all.

Comments

 [2006-04-25 04:26 UTC] alex_lai at hotmail dot com (Alex)
I want to provide my testing result for generating a graph with only one bar in it for v0.7.2. If the x-axis is a Image_Graph_Axis_Category or Image_Graph_Axis, the bar does get plotted. However, the bar is plotted right on the y-axis. If you change the color of the bar graph you will be able to view this. For a logarithmic axis, the single bar is generated correctly. There are existing work arounds for this behavior. If the x-axis is linear, Image_Graph_Axis, then force a minimum and maximum x-axis value and the bar will display nicely. If the x-axis is a category type, Image_Graph_Axis_Category, then add additional value to the dataset with x and y value (y's set to zero) in the desired order to have it appear on the x-axis. A possible appropriate behavior is to modify the code to let users input an offset value from the y-axis for the first value on the x-axis or vice versa, something like, setAxisOffset. This would also be beneficial for logarithmic axis as well. Alex
 [2007-09-30 20:31 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2008-03-04 00:09 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2009-11-20 10:57 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2011-08-28 16:24 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2012-01-27 19:42 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!