summaryrefslogtreecommitdiffstats
path: root/src/graph.php
blob: 244dd5fc7ca16db9bdea567279845b1bb0f0bc6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
 * File containing the abstract ezcGraph 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
 */
/**
 * Base options class for all eZ components.
 *
 * @package Graph
 */
class ezcGraph
{

    const NO_SYMBOL = 0;
    const DIAMOND = 1;
    const BULLET = 2;
    const CIRCLE = 3;

    const TOP = 1;
    const BOTTOM = 2;
    const LEFT = 4;
    const RIGHT = 8;
    const CENTER = 16;
    const MIDDLE = 32;

    static protected $chartTypes = array(
        'pie'   => 'ezcGraphPieChart',
        'line'  => 'ezcGraphLineChart',
    );

    /**
     * create 
     * 
     * @param string $type Type of chart to create
     * @param array $options Options to create the chart with
     * @throws ezcGraphUnknownChartTypeException
     * @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);
        }
    }

    /**
     * Creates a palette from given name
     * 
     * @param string $name Name of the palette
     * @return ezcGraphPalette Created palette
     */
    static public function createPalette( $name )
    {
        $className = 'ezcGraphPalette' . $name;
        if ( class_exists( $className ) )
        {
            return new $className();
        }
        else
        {
            throw new ezcGraphUnknownPaletteException( $name );
        }
    }
}

?>
OpenPOWER on IntegriCloud