summaryrefslogtreecommitdiffstats
path: root/src/axis/labeled.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-05-26 09:50:50 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-05-26 09:50:50 +0000
commit89a8010b0b0869d07cb1d433351a1334bf232c57 (patch)
tree599f48a7030ba23dcb7e92f36cbcf082272dd681 /src/axis/labeled.php
parentf13db279e32e2a4c323f5edeec486463e29fefc8 (diff)
downloadzetacomponents-graph-89a8010b0b0869d07cb1d433351a1334bf232c57.zip
zetacomponents-graph-89a8010b0b0869d07cb1d433351a1334bf232c57.tar.gz
- Moved axis renderer method to abstract ezcGraphElementAxis class
- Added coordinate calculation tests for both axis types - Implemented coordinate calculation
Diffstat (limited to 'src/axis/labeled.php')
-rw-r--r--src/axis/labeled.php58
1 files changed, 44 insertions, 14 deletions
diff --git a/src/axis/labeled.php b/src/axis/labeled.php
index b10fe6b..50d7489 100644
--- a/src/axis/labeled.php
+++ b/src/axis/labeled.php
@@ -88,19 +88,49 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis
*/
public function getCoordinate( ezcGraphBoundings $boundings, $value )
{
-
- }
-
- /**
- * Render an axe
- *
- * @param ezcGraphRenderer $renderer
- * @access public
- * @return void
- */
- public function render( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings )
- {
- return $boundings;
+ if ( $value === false ||
+ $value === null ||
+ ( $key = array_search( $value, $this->labels ) ) === false )
+ {
+ switch ( $this->position )
+ {
+ case ezcGraph::TOP:
+ return $boundings->y0 +
+ ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 );
+ case ezcGraph::BOTTOM:
+ return $boundings->y1 -
+ ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 );
+ case ezcGraph::LEFT:
+ return $boundings->x0 +
+ ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 );
+ case ezcGraph::RIGHT:
+ return $boundings->x1 -
+ ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 );
+ }
+ }
+ else
+ {
+ switch ( $this->position )
+ {
+ case ezcGraph::TOP:
+ return $boundings->y0 +
+ ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 ) +
+ ( $boundings->y1 - $boundings->y0 ) * ( 1 - $this->padding ) / ( count ( $this->labels ) - 1 ) * $key;
+ case ezcGraph::BOTTOM:
+ return $boundings->y1 -
+ ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 ) -
+ ( $boundings->y1 - $boundings->y0 ) * ( 1 - $this->padding ) / ( count ( $this->labels ) - 1 ) * $key;
+ case ezcGraph::LEFT:
+ return $boundings->x0 +
+ ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 ) +
+ ( $boundings->x1 - $boundings->x0 ) * ( 1 - $this->padding ) / ( count ( $this->labels ) - 1 ) * $key;
+ case ezcGraph::RIGHT:
+ return $boundings->x1 -
+ ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 ) -
+ ( $boundings->x1 - $boundings->x0 ) * ( 1 - $this->padding ) / ( count ( $this->labels ) - 1 ) * $key;
+ }
+ }
}
-
}
+
+?>
OpenPOWER on IntegriCloud