PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Images » Image_Graph » Bug #5971

Image_Graph_Axis_Category does not undersand levels

Details

Request #5971Image_Graph_Axis_Category does not undersand levels
Submitted2005-11-15 16:26 UTC
Fromchebatron at gmail dot com
Assignednosey
StatusAssigned
PackageImage_Graph
PHP Version5.0.3
OSSlackware 10.1
Roadmaps(Not assigned)

Comments

[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.