summaryrefslogtreecommitdiffstats
path: root/src/axis/labeled.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-07-21 14:14:56 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-07-21 14:14:56 +0000
commit49ded86c90d1bfa6cc0b780b1ad00544f9d198fd (patch)
tree29a292b23a6b1af6159fa6fa82515c3aed1097e6 /src/axis/labeled.php
parent14f4f83b181822bb65c55ca76eb0e28157ba43b4 (diff)
downloadzetacomponents-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/labeled.php')
-rw-r--r--src/axis/labeled.php138
1 files changed, 3 insertions, 135 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] ) )
{
OpenPOWER on IntegriCloud