diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-05-08 12:49:09 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-05-08 12:49:09 +0000 |
commit | 0aa04bd66f938b4a7b1fdf05e356b1a68e09217c (patch) | |
tree | c048aeb7914d61f58fd0691ab0bdad412cd4b0e8 /src/graph.php | |
parent | 2ec481fc479ba898c9b4506cdeb9450887a3fa57 (diff) | |
download | zetacomponents-graph-0aa04bd66f938b4a7b1fdf05e356b1a68e09217c.zip zetacomponents-graph-0aa04bd66f938b4a7b1fdf05e356b1a68e09217c.tar.gz |
- Added test for ezcGraph class
- Added basic autoload file
- Implemented factory method for charts
Diffstat (limited to 'src/graph.php')
-rw-r--r-- | src/graph.php | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/graph.php b/src/graph.php index 50425bb..a33a2cb 100644 --- a/src/graph.php +++ b/src/graph.php @@ -12,20 +12,34 @@ * * @package Graph */ -class ezcGraph extends ezcBaseOptions +class ezcGraph { + static protected $chartTypes = array( + 'pie' => 'ezcGraphPieChart', + 'line' => 'ezcGraphLineChart', + ); + /** - * Creates a graph chart instance + * create * - * @param mixed $type + * @param string $type Type of chart to create + * @param array $options Options to create the chart with * @static + * @throw ezcGraphUnknownChartTypeException * @access public - * @return void + * @return ezcGraphChart */ static public function create( $type, $options = array() ) { - + $type = strtolower( $type ); + if ( isset( self::$chartTypes[$type] ) ) + { + $className = self::$chartTypes[$type]; + return new $className( $options ); + } else { + throw new ezcGraphUnknownChartTypeException($type); + } } } |