Added a graphing functionality with Open Flash Chart, and added ability to graph...
[openemr.git] / library / openflashchart / php-ofc-library / ofc_pie.php
blobbf779c55415ac43b0ef46bde0ae195703dbfcd7d
1 <?php
3 class pie_value
5 function pie_value( $value, $label )
7 $this->value = $value;
8 $this->label = $label;
11 function set_colour( $colour )
13 $this->colour = $colour;
16 function set_label( $label, $label_colour, $font_size )
18 $this->label = $label;
20 $tmp = 'label-colour';
21 $this->$tmp = $label_colour;
23 $tmp = 'font-size';
24 $this->$tmp = $font_size;
28 function set_tooltip( $tip )
30 $this->tip = $tip;
33 function on_click( $event )
35 $tmp = 'on-click';
36 $this->$tmp = $event;
40 /**
41 * An object that inherits from base_pie_animation
43 function add_animation( $animation )
45 if( !isset( $this->animate ) )
46 $this->animate = array();
48 $this->animate[] = $animation;
50 return $this;
54 class base_pie_animation{}
56 /**
57 * fade the pie slice from $alpha (pie set_alpha) to 100% opaque.
59 class pie_fade extends base_pie_animation
61 function pie_fade()
63 $this->type="fade";
67 /**
68 * Bounce the pie slice out a little
70 class pie_bounce extends base_pie_animation
72 /**
73 * @param $distance as integer, distance to bounce in pixels
75 function pie_bounce( $distance )
77 $this->type="bounce";
78 $this->distance = $distance;
82 /**
83 * Make a pie chart and fill it with pie slices
85 class pie
87 function pie()
89 $this->type = 'pie';
92 function set_colours( $colours )
94 $this->colours = $colours;
97 /**
98 * Sugar wrapped around set_colours
100 function colours( $colours )
102 $this->set_colours( $colours );
103 return $this;
107 * @param $alpha as float (0-1) 0.75 = 3/4 visible
109 function set_alpha( $alpha )
111 $this->alpha = $alpha;
115 *sugar wrapped set_alpha
117 function alpha( $alpha )
119 $this->set_alpha( $alpha );
120 return $this;
124 * @param $v as array containing one of
125 * - null
126 * - real or integer number
127 * - a pie_value object
129 function set_values( $v )
131 $this->values = $v;
135 * sugar for set_values
137 function values( $v )
139 $this->set_values( $v );
140 return $this;
144 * HACK to keep old code working.
146 function set_animate( $bool )
148 if( $bool )
149 $this->add_animation( new pie_fade() );
154 * An object that inherits from base_pie_animation
156 function add_animation( $animation )
158 if( !isset( $this->animate ) )
159 $this->animate = array();
161 $this->animate[] = $animation;
163 return $this;
167 * @param $angle as real number
169 function set_start_angle( $angle )
171 $tmp = 'start-angle';
172 $this->$tmp = $angle;
176 * sugar for set_start_angle
178 function start_angle($angle)
180 $this->set_start_angle( $angle );
181 return $this;
185 * @param $tip as string. The tooltip text. May contain magic varibles
187 function set_tooltip( $tip )
189 $this->tip = $tip;
193 * sugar for set_tooltip
195 function tooltip( $tip )
197 $this->set_tooltip( $tip );
198 return $this;
201 function set_gradient_fill()
203 $tmp = 'gradient-fill';
204 $this->$tmp = true;
207 function gradient_fill()
209 $this->set_gradient_fill();
210 return $this;
214 * By default each label is the same colour as the slice,
215 * but you can ovveride that behaviour using this method.
217 * @param $label_colour as string HEX colour;
219 function set_label_colour( $label_colour )
221 $tmp = 'label-colour';
222 $this->$tmp = $label_colour;
225 function label_colour( $label_colour )
227 $this->set_label_colour( $label_colour );
228 return $this;
232 * Turn off the labels
234 function set_no_labels()
236 $tmp = 'no-labels';
237 $this->$tmp = true;
240 function on_click( $event )
242 $tmp = 'on-click';
243 $this->$tmp = $event;
247 * Fix the radius of the pie chart. Take a look at the magic variable #radius#
248 * for helping figure out what radius to set it to.
250 * @param $radius as number
252 function radius( $radius )
254 $this->radius = $radius;
255 return $this;