diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2009-07-04 11:07:54 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2009-07-04 11:07:54 +0000 |
commit | e6a99f5e5a8c6e5ea43ebc0ca7d994f2d6c4a689 (patch) | |
tree | fd4280250e3bdd2562ef72e46eca8f715f0b6ff0 /src | |
parent | adc30f0247f83feb0300b6e1c64dfead4e059c3e (diff) | |
download | zetacomponents-graph-e6a99f5e5a8c6e5ea43ebc0ca7d994f2d6c4a689.zip zetacomponents-graph-e6a99f5e5a8c6e5ea43ebc0ca7d994f2d6c4a689.tar.gz |
- Implemented: #14294: Add option for axis label rotation
Diffstat (limited to 'src')
-rw-r--r-- | src/element/axis.php | 11 | ||||
-rw-r--r-- | src/renderer/2d.php | 24 |
2 files changed, 31 insertions, 4 deletions
diff --git a/src/element/axis.php b/src/element/axis.php index e356c0e..4f38761 100644 --- a/src/element/axis.php +++ b/src/element/axis.php @@ -120,6 +120,8 @@ * @property-read bool $initialized * Property indicating if some values were associated with axis, or a * scaling has been set manually. + * @property float $labelRotation + * Rotation of the axis label in degree * * @version //autogentag// * @package Graph @@ -166,6 +168,7 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement $this->properties['labelCallback'] = null; $this->properties['chartPosition'] = null; $this->properties['initialized'] = false; + $this->properties['labelRotation'] = 0.; parent::__construct( $options ); @@ -327,6 +330,14 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement $this->properties['chartPosition'] = (float) $propertyValue; break; + case 'labelRotation': + if ( !is_numeric( $propertyValue ) ) + { + throw new ezcBaseValueException( $propertyName, $propertyValue, 'float' ); + } + + $this->properties['labelRotation'] = fmod( (float) $propertyValue, 360. ); + break; default: parent::__set( $propertyName, $propertyValue ); break; diff --git a/src/renderer/2d.php b/src/renderer/2d.php index 082f2c3..4cb5ce0 100644 --- a/src/renderer/2d.php +++ b/src/renderer/2d.php @@ -1425,7 +1425,11 @@ class ezcGraphRenderer2d ), $width * ( 1 - $axis->axisSpace * 2 ) - $axis->labelMargin, $axis->labelSize, - ezcGraph::TOP | ezcGraph::RIGHT + ezcGraph::TOP | ezcGraph::RIGHT, + new ezcGraphRotation( $axis->labelRotation, new ezcGraphCoordinate( + $position->x + $axis->labelSize / 2, + $position->y - $axis->labelSize / 2 + ) ) ); break; case ezcGraph::BOTTOM: @@ -1437,7 +1441,11 @@ class ezcGraphRenderer2d ), $width * ( 1 - $axis->axisSpace * 2 ) - $axis->labelMargin, $axis->labelSize, - ezcGraph::TOP | ezcGraph::LEFT + ezcGraph::TOP | ezcGraph::LEFT, + new ezcGraphRotation( $axis->labelRotation, new ezcGraphCoordinate( + $position->x + $axis->labelSize / 2, + $position->y + $axis->labelSize / 2 + ) ) ); break; case ezcGraph::LEFT: @@ -1449,7 +1457,11 @@ class ezcGraphRenderer2d ), $width - $axis->labelMargin, $axis->labelSize, - ezcGraph::BOTTOM | ezcGraph::RIGHT + ezcGraph::BOTTOM | ezcGraph::RIGHT, + new ezcGraphRotation( $axis->labelRotation, new ezcGraphCoordinate( + $position->x - $axis->labelSize / 2, + $position->y - $axis->labelSize / 2 + ) ) ); break; case ezcGraph::RIGHT: @@ -1461,7 +1473,11 @@ class ezcGraphRenderer2d ), $width - $axis->labelMargin, $axis->labelSize, - ezcGraph::BOTTOM | ezcGraph::LEFT + ezcGraph::BOTTOM | ezcGraph::LEFT, + new ezcGraphRotation( $axis->labelRotation, new ezcGraphCoordinate( + $position->x + $axis->labelSize / 2, + $position->y - $axis->labelSize / 2 + ) ) ); break; } |