diff options
-rw-r--r-- | src/element/axis.php | 14 | ||||
-rw-r--r-- | tests/multiple_axis_test.php | 29 |
2 files changed, 43 insertions, 0 deletions
diff --git a/src/element/axis.php b/src/element/axis.php index 30af47a..fabc25d 100644 --- a/src/element/axis.php +++ b/src/element/axis.php @@ -42,6 +42,9 @@ * Function will receive two parameters and should return a * reformatted label. * string function( label, step ) + * @property float $chartPosition + * Position of the axis in the chart. Only useful for additional + * axis. The basic chart axis will be automatically positioned. * * @version //autogentag// * @package Graph @@ -77,6 +80,7 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement $this->properties['minArrowHeadSize'] = 4; $this->properties['maxArrowHeadSize'] = 8; $this->properties['labelCallback'] = null; + $this->properties['chartPosition'] = null; parent::__construct( $options ); @@ -215,6 +219,16 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement throw new ezcBaseValueException( $propertyName, $propertyValue, 'callback function' ); } break; + case 'chartPosition': + if ( !is_numeric( $propertyValue ) || + ( $propertyValue < 0 ) || + ( $propertyValue > 1 ) ) + { + throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' ); + } + + $this->properties['chartPosition'] = (float) $propertyValue; + break; default: parent::__set( $propertyName, $propertyValue ); break; diff --git a/tests/multiple_axis_test.php b/tests/multiple_axis_test.php index d67231b..ab32db8 100644 --- a/tests/multiple_axis_test.php +++ b/tests/multiple_axis_test.php @@ -68,6 +68,35 @@ class ezcGraphMultipleAxisTest extends ezcTestCase $this->fail( 'Expected ezcBaseValueException.' ); } + public function testAxisPropertyChartPosition() + { + $options = new ezcGraphChartElementNumericAxis(); + + $this->assertEquals( + null, + $options->chartPosition, + 'Wrong default value for property chartPosition in class ezcGraphChartElementNumericAxis' + ); + + $options->chartPosition = .3; + $this->assertSame( + .3, + $options->chartPosition, + 'Setting property value did not work for property chartPosition in class ezcGraphChartElementNumericAxis' + ); + + try + { + $options->chartPosition = 15; + } + catch ( ezcBaseValueException $e ) + { + return true; + } + + $this->fail( 'Expected ezcBaseValueException.' ); + } + public function testAxisContainerIterator() { $options = new ezcGraphLineChartOptions(); |