source: code/Website/php5-ofc-library/lib/OFC/OFC_Chart.php

Last change on this file was 7849, checked in by dennisw, 15 years ago
File size: 2.7 KB
Line 
1<?php
2/**
3 * PHP Integration of Open Flash Chart
4 * Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21if (! function_exists('json_encode'))
22{
23 require_once('OFC/JSON.php');
24}
25
26require_once('OFC/JSON_Format.php');
27
28require_once('OFC/OFC_Elements.php');
29
30require_once('OFC/Charts/OFC_Charts_Area.php');
31require_once('OFC/Charts/OFC_Charts_Bar.php');
32require_once('OFC/Charts/OFC_Charts_Line.php');
33require_once('OFC/Charts/OFC_Charts_Pie.php');
34require_once('OFC/Charts/OFC_Charts_Scatter.php');
35require_once('OFC/Charts/Area/OFC_Charts_Area_Hollow.php');
36require_once('OFC/Charts/Bar/OFC_Charts_Bar_Filled.php');
37require_once('OFC/Charts/Bar/OFC_Charts_Bar_3d.php');
38require_once('OFC/Charts/Bar/OFC_Charts_Bar_Glass.php');
39require_once('OFC/Charts/Bar/OFC_Charts_Bar_Horizontal.php');
40require_once('OFC/Charts/Bar/OFC_Charts_Bar_Sketch.php');
41require_once('OFC/Charts/Bar/OFC_Charts_Bar_Stack.php');
42require_once('OFC/Charts/Line/OFC_Charts_Line_Dot.php');
43require_once('OFC/Charts/Line/OFC_Charts_Line_Hollow.php');
44
45class OFC_Chart
46{
47 function OFC_Chart()
48 {
49 $this->title = new OFC_Elements_Title( "Many data lines" );
50 $this->elements = array();
51 }
52
53 function set_title( $t )
54 {
55 $this->title = $t;
56 }
57
58 function set_x_axis( $x )
59 {
60 $this->x_axis = $x;
61 }
62
63 function set_y_axis( $y )
64 {
65 $this->y_axis = $y;
66 }
67
68 function add_y_axis( $y )
69 {
70 $this->y_axis = $y;
71 }
72
73 function set_y_axis_right( $y )
74 {
75 $this->y_axis_right = $y;
76 }
77
78 function add_element( $e )
79 {
80 $this->elements[] = $e;
81 }
82
83 function set_x_legend( $x )
84 {
85 $this->x_legend = $x;
86 }
87
88 function set_y_legend( $y )
89 {
90 $this->y_legend = $y;
91 }
92
93 function set_bg_colour( $colour )
94 {
95 $this->bg_colour = $colour;
96 }
97
98 function toString()
99 {
100 if (function_exists('json_encode'))
101 {
102 return json_encode($this);
103 }
104 else
105 {
106 $json = new Services_JSON();
107 return $json->encode( $this );
108 }
109 }
110
111 function toPrettyString()
112 {
113 return json_format( $this->toString() );
114 }
115}
116
Note: See TracBrowser for help on using the repository browser.