Added a graphing functionality with Open Flash Chart, and added ability to graph...
[openemr.git] / library / openflashchart / php-ofc-library / open-flash-chart.php
blobb017097d00524cfb2fc14831ac71584f19c704c7
1 <?php
3 // var_dump(debug_backtrace());
5 //
6 // Omar Kilani's php C extension for encoding JSON has been incorporated in stock PHP since 5.2.0
7 // http://www.aurore.net/projects/php-json/
8 //
9 // -- Marcus Engene
11 if (! function_exists('json_encode'))
13 include_once 'JSON.php';
16 include_once 'json_format.php';
18 // ofc classes
19 include_once 'ofc_title.php';
20 include_once 'ofc_y_axis_base.php';
21 include_once 'ofc_y_axis.php';
22 include_once 'ofc_y_axis_right.php';
23 include_once 'ofc_y_axis_labels.php';
24 include_once 'ofc_y_axis_label.php';
25 include_once 'ofc_x_axis.php';
28 include_once 'ofc_pie.php';
29 //include_once 'ofc_bar.php';
30 include_once 'ofc_bar_glass.php';
31 include_once 'ofc_bar_filled.php';
32 include_once 'ofc_bar_stack.php';
33 //include_once 'ofc_bar_3d.php';
34 include_once 'ofc_hbar.php';
35 include_once 'ofc_line_base.php';
36 include_once 'ofc_line.php';
37 //include_once 'ofc_line_dot.php';
38 //include_once 'ofc_line_hollow.php';
39 include_once 'ofc_candle.php';
40 include_once 'ofc_area_base.php';
41 include_once 'ofc_tags.php';
42 include_once 'ofc_arrow.php';
43 //include_once 'ofc_area_hollow.php';
44 //include_once 'ofc_area_line.php';
46 include_once 'ofc_x_legend.php';
47 include_once 'ofc_y_legend.php';
48 include_once 'ofc_bar_sketch.php';
49 include_once 'ofc_scatter.php';
50 include_once 'ofc_scatter_line.php';
51 include_once 'ofc_x_axis_labels.php';
52 include_once 'ofc_x_axis_label.php';
53 include_once 'ofc_tooltip.php';
54 include_once 'ofc_shape.php';
55 include_once 'ofc_radar_axis.php';
56 include_once 'ofc_radar_axis_labels.php';
57 include_once 'ofc_radar_spoke_labels.php';
58 include_once 'ofc_line_style.php';
60 include_once 'dot_base.php';
61 include_once 'ofc_menu.php';
63 class open_flash_chart
65 function open_flash_chart()
67 //$this->title = new title( "Many data lines" );
68 $this->elements = array();
71 function set_title( $t )
73 $this->title = $t;
76 function set_x_axis( $x )
78 $this->x_axis = $x;
81 function set_y_axis( $y )
83 $this->y_axis = $y;
86 function add_y_axis( $y )
88 $this->y_axis = $y;
91 function set_y_axis_right( $y )
93 $this->y_axis_right = $y;
96 function add_element( $e )
98 $this->elements[] = $e;
101 function set_x_legend( $x )
103 $this->x_legend = $x;
106 function set_y_legend( $y )
108 $this->y_legend = $y;
111 function set_bg_colour( $colour )
113 $this->bg_colour = $colour;
116 function set_radar_axis( $radar )
118 $this->radar_axis = $radar;
121 function set_tooltip( $tooltip )
123 $this->tooltip = $tooltip;
127 * This is a bit funky :(
129 * @param $num_decimals as integer. Truncate the decimals to $num_decimals, e.g. set it
130 * to 5 and 3.333333333 will display as 3.33333. 2.0 will display as 2 (or 2.00000 - see below)
131 * @param $is_fixed_num_decimals_forced as boolean. If true it will pad the decimals.
132 * @param $is_decimal_separator_comma as boolean
133 * @param $is_thousand_separator_disabled as boolean
135 * This needs a bit of love and attention
137 function set_number_format($num_decimals, $is_fixed_num_decimals_forced, $is_decimal_separator_comma, $is_thousand_separator_disabled )
139 $this->num_decimals = $num_decimals;
140 $this->is_fixed_num_decimals_forced = $is_fixed_num_decimals_forced;
141 $this->is_decimal_separator_comma = $is_decimal_separator_comma;
142 $this->is_thousand_separator_disabled = $is_thousand_separator_disabled;
146 * This is experimental and will change as we make it work
148 * @param $m as ofc_menu
150 function set_menu($m)
152 $this->menu = $m;
155 function toString()
157 if (function_exists('json_encode'))
159 return json_encode($this);
161 else
163 $json = new Services_JSON();
164 return $json->encode( $this );
168 function toPrettyString()
170 return json_format( $this->toString() );
177 // there is no PHP end tag so we don't mess the headers up!