diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-05-24 12:08:41 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-05-24 12:08:41 +0000 |
commit | 67dd64c82d83deaa6bf11108d5aba766c188681e (patch) | |
tree | 8094e8cd55e88c18f39a76ec847895fba614d79c /src/axis/labeled.php | |
parent | eb7d6e8d3679a4680a20a43a3c949120c3d61ea2 (diff) | |
download | zetacomponents-graph-67dd64c82d83deaa6bf11108d5aba766c188681e.zip zetacomponents-graph-67dd64c82d83deaa6bf11108d5aba766c188681e.tar.gz |
- Fixed filenames for axis classes
Diffstat (limited to 'src/axis/labeled.php')
-rw-r--r-- | src/axis/labeled.php | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/src/axis/labeled.php b/src/axis/labeled.php new file mode 100644 index 0000000..b10fe6b --- /dev/null +++ b/src/axis/labeled.php @@ -0,0 +1,106 @@ +<?php +/** + * File containing the abstract ezcGraphChartElementLabeledAxis class + * + * @package Graph + * @version //autogentag// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ +/** + * Class to represent a axe as a chart element + * + * @package Graph + */ +class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis +{ + + /** + * Array with labeles for data + * + * @var array + */ + protected $labels = array(); + + protected function increaseKeys( $array, $startKey ) + { + foreach ( $array as $key => $value ) + { + if ( $key === $startKey ) + { + // Recursive check, if next key should be increased, too + if ( isset ( $array[$key + 1] ) ) + { + $array = $this->increaseKeys( $array, $key + 1 ); + } + + // Increase key + $array[$key + 1] = $array[$key]; + unset( $array[$key] ); + } + } + + return $array; + } + + /** + * Get labels from datasets in right order to be rendered later + * + * @param array $datasets + * @return void + */ + public function calculateFromDataset(array $datasets) + { + foreach ( $datasets as $dataset ) + { + $position = 0; + foreach ( $dataset as $label => $value ) + { + $label = (string) $label; + + if ( !in_array( $label, $this->labels, true ) ) + { + if ( isset( $this->labels[$position] ) ) + { + $this->labels = $this->increaseKeys( $this->labels, $position ); + $this->labels[$position++] = $label; + } + else + { + $this->labels[$position++] = $label; + } + } + else + { + $position = array_search( $label, $this->labels, true ) + 1; + } + } + ksort( $this->labels ); + } + } + + /** + * Get coordinate for a dedicated value on the chart + * + * @param ezcGraphBounding $boundings + * @param string $value Value to determine position for + * @return float Position on chart + */ + 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; + } + +} |