diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-07-21 14:14:56 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-07-21 14:14:56 +0000 |
commit | 49ded86c90d1bfa6cc0b780b1ad00544f9d198fd (patch) | |
tree | 29a292b23a6b1af6159fa6fa82515c3aed1097e6 /src/axis | |
parent | 14f4f83b181822bb65c55ca76eb0e28157ba43b4 (diff) | |
download | zetacomponents-graph-49ded86c90d1bfa6cc0b780b1ad00544f9d198fd.zip zetacomponents-graph-49ded86c90d1bfa6cc0b780b1ad00544f9d198fd.tar.gz |
- Readded drawing of axis steps and grids (only available in
ezcGraphAxisExactLabelRenderer yet)
Diffstat (limited to 'src/axis')
-rw-r--r-- | src/axis/labeled.php | 138 | ||||
-rw-r--r-- | src/axis/numeric.php | 6 |
2 files changed, 6 insertions, 138 deletions
diff --git a/src/axis/labeled.php b/src/axis/labeled.php index 132200f..1d202ce 100644 --- a/src/axis/labeled.php +++ b/src/axis/labeled.php @@ -165,7 +165,7 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis * * @return integer Count of minor steps */ - protected function getMinorStepCount() + public function getMinorStepCount() { return 0; } @@ -175,150 +175,18 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis * * @return integer Count of major steps */ - protected function getMajorStepCount() + public function getMajorStepCount() { return count( $this->displayedLabels ) - 1; } /** - * Draw labels for an axis - * - * @param ezcGraphRenderer $renderer - * @param ezcGraphCoordinate $start - * @param ezcGraphCoordinate $end - * @param ezcGraphBoundings $boundings - * @return void - */ - protected function drawLabels( ezcGraphRenderer $renderer, ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphBoundings $boundings ) - { - // Draw major steps - $steps = $this->getMajorStepCount() + 1; - - // Calculate stepsize - $xStepsize = ( $end->x - $start->x ) / $steps; - $yStepsize = ( $end->y - $start->y ) / $steps; - - // Caluclate datafree chart border - $xBorder = abs ( ( $boundings->x1 - $boundings->x0 ) * ( $this->axisSpace / 2 ) ); - $yBorder = abs ( ( $boundings->y1 - $boundings->y0 ) * ( $this->axisSpace / 2 ) ); - - for ( $i = 0; $i <= $steps; ++$i ) - { - $label = sprintf( $this->formatString, $this->getLabel( $i ) ); - - switch ( $this->position ) - { - case ezcGraph::LEFT: - if ( $i === 0 ) - { - $align = ezcGraph::LEFT; - } - elseif ( $i >= ( $steps - 1 ) ) - { - $align = ezcGraph::RIGHT; - } - else - { - $align = ezcGraph::CENTER; - } - - $renderer->drawTextBox( - new ezcGraphCoordinate( - (int) round( $start->x + $i * $xStepsize + $this->labelPadding ), - (int) round( $start->y + $i * $yStepsize + $this->labelPadding ) - ), - $label, - (int) round( $xStepsize ) - $this->labelPadding, - $yBorder - $this->labelPadding, - $align | ezcGraph::TOP - ); - break; - case ezcGraph::RIGHT: - if ( $i === 0 ) - { - $align = ezcGraph::RIGHT; - } - elseif ( $i >= ( $steps - 1 ) ) - { - $align = ezcGraph::LEFT; - } - else - { - $align = ezcGraph::CENTER; - } - - $renderer->drawTextBox( - new ezcGraphCoordinate( - (int) round( $start->x + $i * $xStepsize + $xStepsize ), - (int) round( $start->y + $i * $yStepsize + $this->labelPadding ) - ), - $label, - (int) round( -$xStepsize ) - $this->labelPadding, - $yBorder - $this->labelPadding, - $align | ezcGraph::TOP - ); - break; - case ezcGraph::BOTTOM: - if ( $i === 0 ) - { - $align = ezcGraph::BOTTOM; - } - elseif ( $i >= ( $steps - 1 ) ) - { - $align = ezcGraph::TOP; - } - else - { - $align = ezcGraph::MIDDLE; - } - - $renderer->drawTextBox( - new ezcGraphCoordinate( - (int) round( $start->x + $i * $xStepsize - $xBorder ), - (int) round( $start->y + $i * $yStepsize + $yStepsize ) - ), - $label, - $xBorder - $this->labelPadding, - (int) round( -$yStepsize ) - $this->labelPadding, - ezcGraph::RIGHT | $align - ); - break; - case ezcGraph::TOP: - if ( $i === 0 ) - { - $align = ezcGraph::TOP; - } - elseif ( $i >= ( $steps - 1 ) ) - { - $align = ezcGraph::BOTTOM; - } - else - { - $align = ezcGraph::MIDDLE; - } - - $renderer->drawTextBox( - new ezcGraphCoordinate( - (int) round( $start->x + $i * $xStepsize - $xBorder ), - (int) round( $start->y + $i * $yStepsize + $this->labelPadding ) - ), - $label, - $xBorder - $this->labelPadding, - (int) round( $yStepsize ) - $this->labelPadding, - ezcGraph::RIGHT | $align - ); - break; - } - } - } - - /** * Get label for a dedicated step on the axis * * @param integer $step Number of step * @return string label */ - protected function getLabel( $step ) + public function getLabel( $step ) { if ( isset( $this->displayedLabels[$step] ) ) { diff --git a/src/axis/numeric.php b/src/axis/numeric.php index f0cfc24..023a9ea 100644 --- a/src/axis/numeric.php +++ b/src/axis/numeric.php @@ -301,7 +301,7 @@ class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis * * @return integer Count of minor steps */ - protected function getMinorStepCount() + public function getMinorStepCount() { return (int) ( ( $this->max - $this->min ) / $this->minorStep ); } @@ -311,7 +311,7 @@ class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis * * @return integer Count of major steps */ - protected function getMajorStepCount() + public function getMajorStepCount() { return (int) ( ( $this->max - $this->min ) / $this->majorStep ); } @@ -463,7 +463,7 @@ class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis * @param integer $step Number of step * @return string label */ - protected function getLabel( $step ) + public function getLabel( $step ) { return $this->min + ( $step * $this->majorStep ); } |