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

Request #5971 Image_Graph_Axis_Category does not undersand levels
Submitted: 2005-11-15 16:26 UTC
From: chebatron at gmail dot com Assigned: nosey
Status: Assigned Package: Image_Graph
PHP Version: 5.0.3 OS: Slackware 10.1
Roadmaps: (Not assigned)    
Subscription  


 [2005-11-15 16:26 UTC] chebatron at gmail dot com
Description: ------------ Category Axis does not understend levels. All operations such as setLabelInterval and others are perfomed on the first (1) level. Test script: --------------- == Test script == <?php require_once 'Image/Graph.php'; $Graph =& Image_Graph::factory('graph', array(800, 300)); $Plotarea =& $Graph->addNew('plotarea'); $Dataset =& Image_Graph::factory('dataset'); // adding some data with time labels $Dataset->addPoint('10:00', 1); $Dataset->addPoint('10:30', 1); $Dataset->addPoint('11:00', 1); $Dataset->addPoint('11:30', 1); $Dataset->addPoint('12:00', 1); $Dataset->addPoint('12:30', 1); $Dataset->addPoint('13:00', 1); $Dataset->addPoint('13:30', 1); $Dataset->addPoint('14:00', 1); $Plot =& $Plotarea->addNew('line', array(&$Dataset)); $AxisX =& $Plotarea->addNew('Image_Graph_Axis_Category', IMAGE_GRAPH_AXIS_X); // showing labels and ticks for everyt second point (every hour) $AxisX->setLabelInterval(2, 1); // showing ticks without labels for every point (half an hour ticks) $AxisX->setLabelInterval(1, 2); $AxisX->setLabelOption('showtext', false, 2); $Graph->done(); ?> == Fix (not fully tested but works for me) == --- Category.php-fixed 2005-11-15 17:38:59.000000000 +0200 +++ Category.php-original 2005-11-15 17:17:31.000000000 +0200 @@ -154,9 +154,9 @@ function setLabelInterval($labelInterval = 'auto', $level = 1) { if ($labelInterval == 'auto') { - parent::setLabelInterval(1, $level); + parent::setLabelInterval(1); } else { - parent::setLabelInterval(round($labelInterval), $level); + parent::setLabelInterval(round($labelInterval)); } } @@ -369,8 +369,8 @@ reset($this->_labels); } $result = false; - $count = ($currentLabel === false ? $this->_labelInterval($level) - 1 : 0); - while ($count < $this->_labelInterval($level)) { + $count = ($currentLabel === false ? $this->_labelInterval() - 1 : 0); + while ($count < $this->_labelInterval()) { $result = (list($label) = each($this->_labels)); $count++; } @@ -410,11 +410,9 @@ $this->_drawAxisLines(); $this->_canvas->startGroup(get_class($this) . '_ticks'); - foreach ($this->_labelOptions as $level => $labelOption) { - $label = false; - while (($label = $this->_getNextLabel($label, $level)) !== false) { - $this->_drawTick($label, $level); - } + $label = false; + while (($label = $this->_getNextLabel($label)) !== false) { + $this->_drawTick($label); } $this->_canvas->endGroup(); @@ -425,4 +423,4 @@ } -?> +?> \ No newline at end of file Expected result: ---------------- I expect to see labels for full hours but not for every tick. Actual result: -------------- Instead I see labels for every tick.

Comments

 [2005-11-16 18:45 UTC] nosey
You are right it does not understand levels, but it is definitely not a bug it is by purpose - or intended, or laziness, or whatever :) "Level-ing" was actually thought of as levels would be 2 (or more) "sets" or "scales" of the data, and since the categories on the category axis are not related on a scale as such (except they are sequential) levelling does not make much "sense". But I see what you are trying to achieve and it could be a nice feature. Your fix does not quite do the trick though (except you are well on the way!), but the size of the axis is still only calculated on a 1-level basis (so you were to rotate your x-axis 90 degrees, your 2nd level would probably disappear of the bottom of your graph). So the size() method need also be changed. I will analyze your patch further and implement this (changed category to Feature Request)