diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2007-09-04 09:53:56 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2007-09-04 09:53:56 +0000 |
commit | 86d31a8b94e881ad6640bd8fd6c450f15fceb96a (patch) | |
tree | 1a84067fa49fb28bddb1d024aec329286f4b0543 /src | |
parent | 6e5582742fb0e67b71e94e0a9bedc91723c3ef3e (diff) | |
download | zetacomponents-graph-86d31a8b94e881ad6640bd8fd6c450f15fceb96a.zip zetacomponents-graph-86d31a8b94e881ad6640bd8fd6c450f15fceb96a.tar.gz |
- Added dataset properties for axis assignements
# More progress on the way to multiple axis support
Diffstat (limited to 'src')
-rw-r--r-- | src/datasets/base.php | 9 | ||||
-rw-r--r-- | src/datasets/property/axis.php | 56 | ||||
-rw-r--r-- | src/exceptions/invalid_assignement.php | 31 | ||||
-rw-r--r-- | src/graph_autoload.php | 2 | ||||
-rw-r--r-- | src/interfaces/dataset_property.php | 2 |
5 files changed, 99 insertions, 1 deletions
diff --git a/src/datasets/base.php b/src/datasets/base.php index 3a3ac80..37337f5 100644 --- a/src/datasets/base.php +++ b/src/datasets/base.php @@ -23,6 +23,10 @@ * Display type of chart data * @property string $url * URL associated with datapoint + * @property ezcGraphChartElementAxis $xAxis + * Associate dataset with a different X axis then the default one + * @property ezcGraphChartElementAxis $yAxis + * Associate dataset with a different Y axis then the default one * * @version //autogentag// * @package Graph @@ -75,6 +79,9 @@ abstract class ezcGraphDataSet implements ArrayAccess, Iterator, Countable $this->properties['displayType'] = new ezcGraphDataSetIntProperty( $this ); $this->properties['url'] = new ezcGraphDataSetStringProperty( $this ); + $this->properties['xAxis'] = new ezcGraphDataSetAxisProperty( $this ); + $this->properties['yAxis'] = new ezcGraphDataSetAxisProperty( $this ); + $this->properties['highlight']->default = false; } @@ -102,6 +109,8 @@ abstract class ezcGraphDataSet implements ArrayAccess, Iterator, Countable case 'symbol': case 'highlight': case 'displayType': + case 'xAxis': + case 'yAxis': $this->properties[$propertyName]->default = $propertyValue; break; diff --git a/src/datasets/property/axis.php b/src/datasets/property/axis.php new file mode 100644 index 0000000..a989f31 --- /dev/null +++ b/src/datasets/property/axis.php @@ -0,0 +1,56 @@ +<?php +/** + * File containing the abstract ezcGraphDataSetIntProperty class + * + * @package Graph + * @version //autogentag// + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ +/** + * Class for axis properties of datasets + * + * @version //autogentag// + * @package Graph + */ +class ezcGraphDataSetAxisProperty extends ezcGraphDataSetProperty +{ + /** + * Chacks if value is really an axis + * + * @param &$value + * @return void + */ + protected function checkValue( &$value ) + { + if ( ! $value instanceof ezcGraphChartElementAxis ) + { + throw new ezcBaseValueException( 'default', $value, 'ezcGraphChartElementAxis' ); + } + + return true; + } + + /** + * Set an option. + * + * Sets an option using ArrayAccess. + * + * This is deaktivated, because you need not set a different axis for some + * data point. + * + * @param string $key The option to set. + * @param mixed $value The value for the option. + * @return void + * + * @throws ezcGraphInvalidAssignementException + * Always + */ + public function offsetSet( $key, $value ) + { + throw new ezcGraphInvalidAssignementException(); + } + +} + +?> diff --git a/src/exceptions/invalid_assignement.php b/src/exceptions/invalid_assignement.php new file mode 100644 index 0000000..2271c98 --- /dev/null +++ b/src/exceptions/invalid_assignement.php @@ -0,0 +1,31 @@ +<?php +/** + * File containing the ezcGraphInvalidAssignementException class + * + * @package Graph + * @version //autogentag// + * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ +/** + * Exception thrown, when trying a property cannot be set for a data point, but + * only for data sets. + * + * @package Graph + * @version //autogentag// + */ +class ezcGraphInvalidAssignementException extends ezcGraphException +{ + /** + * Constructor + * + * @return void + * @ignore + */ + public function __construct() + { + parent::__construct( "This cannot be set on data points, but only for data sets." ); + } +} + +?> diff --git a/src/graph_autoload.php b/src/graph_autoload.php index 495d77d..1be0248 100644 --- a/src/graph_autoload.php +++ b/src/graph_autoload.php @@ -18,6 +18,7 @@ return array( 'ezcGraphFontRenderingException' => 'Graph/exceptions/font_rendering.php', 'ezcGraphGdDriverUnsupportedImageTypeException' => 'Graph/exceptions/unsupported_image_type.php', 'ezcGraphInvalidArrayDataSourceException' => 'Graph/exceptions/invalid_data_source.php', + 'ezcGraphInvalidAssignementException' => 'Graph/exceptions/invalid_assignement.php', 'ezcGraphInvalidDataException' => 'Graph/exceptions/invalid_data.php', 'ezcGraphInvalidDisplayTypeException' => 'Graph/exceptions/invalid_display_type.php', 'ezcGraphInvalidFontTypeException' => 'Graph/exceptions/invalid_font.php', @@ -78,6 +79,7 @@ return array( 'ezcGraphChartSingleDataContainer' => 'Graph/data_container/single.php', 'ezcGraphContext' => 'Graph/structs/context.php', 'ezcGraphDataSetAveragePolynom' => 'Graph/datasets/average.php', + 'ezcGraphDataSetAxisProperty' => 'Graph/datasets/property/axis.php', 'ezcGraphDataSetBooleanProperty' => 'Graph/datasets/property/boolean.php', 'ezcGraphDataSetColorProperty' => 'Graph/datasets/property/color.php', 'ezcGraphDataSetIntProperty' => 'Graph/datasets/property/integer.php', diff --git a/src/interfaces/dataset_property.php b/src/interfaces/dataset_property.php index fe6a3d7..e7f3137 100644 --- a/src/interfaces/dataset_property.php +++ b/src/interfaces/dataset_property.php @@ -138,7 +138,7 @@ abstract class ezcGraphDataSetProperty implements ArrayAccess * @throws ezcBaseValueException * If a the value for a property is out of range. */ - final public function offsetSet( $key, $value ) + public function offsetSet( $key, $value ) { if ( isset( $this->dataset[$key] ) && $this->checkValue( $value ) ) |