1 | <?php
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * A private class. All the other line-dots inherit from this.
|
---|
5 | * Gives them all some common methods.
|
---|
6 | */
|
---|
7 | class dot_base
|
---|
8 | {
|
---|
9 | /**
|
---|
10 | * @param $type string
|
---|
11 | * @param $value integer
|
---|
12 | */
|
---|
13 | function dot_base($type, $value=null)
|
---|
14 | {
|
---|
15 | $this->type = $type;
|
---|
16 | if( isset( $value ) )
|
---|
17 | $this->value( $value );
|
---|
18 | }
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * For line charts that only require a Y position
|
---|
22 | * for each point.
|
---|
23 | * @param $value as integer, the Y position
|
---|
24 | */
|
---|
25 | function value( $value )
|
---|
26 | {
|
---|
27 | $this->value = $value;
|
---|
28 | }
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * For scatter charts that require an X and Y position for
|
---|
32 | * each point.
|
---|
33 | *
|
---|
34 | * @param $x as integer
|
---|
35 | * @param $y as integer
|
---|
36 | */
|
---|
37 | function position( $x, $y )
|
---|
38 | {
|
---|
39 | $this->x = $x;
|
---|
40 | $this->y = $y;
|
---|
41 | }
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * @param $colour is a string, HEX colour, e.g. '#FF0000' red
|
---|
45 | */
|
---|
46 | function colour($colour)
|
---|
47 | {
|
---|
48 | $this->colour = $colour;
|
---|
49 | return $this;
|
---|
50 | }
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * The tooltip for this dot.
|
---|
54 | */
|
---|
55 | function tooltip( $tip )
|
---|
56 | {
|
---|
57 | $this->tip = $tip;
|
---|
58 | return $this;
|
---|
59 | }
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * @param $size is an integer. Size of the dot.
|
---|
63 | */
|
---|
64 | function size($size)
|
---|
65 | {
|
---|
66 | $tmp = 'dot-size';
|
---|
67 | $this->$tmp = $size;
|
---|
68 | return $this;
|
---|
69 | }
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * a private method
|
---|
73 | */
|
---|
74 | function type( $type )
|
---|
75 | {
|
---|
76 | $this->type = $type;
|
---|
77 | return $this;
|
---|
78 | }
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * @param $size is an integer. The size of the hollow 'halo' around the dot that masks the line.
|
---|
82 | */
|
---|
83 | function halo_size( $size )
|
---|
84 | {
|
---|
85 | $tmp = 'halo-size';
|
---|
86 | $this->$tmp = $size;
|
---|
87 | return $this;
|
---|
88 | }
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * @param $do as string. One of three options (examples):
|
---|
92 | * - "http://example.com" - browse to this URL
|
---|
93 | * - "https://example.com" - browse to this URL
|
---|
94 | * - "trace:message" - print this message in the FlashDevelop debug pane
|
---|
95 | * - all other strings will be called as Javascript functions, so a string "hello_world"
|
---|
96 | * will call the JS function "hello_world(index)". It passes in the index of the
|
---|
97 | * point.
|
---|
98 | */
|
---|
99 | function on_click( $do )
|
---|
100 | {
|
---|
101 | $tmp = 'on-click';
|
---|
102 | $this->$tmp = $do;
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * Draw a hollow dot
|
---|
108 | */
|
---|
109 | class hollow_dot extends dot_base
|
---|
110 | {
|
---|
111 | function hollow_dot($value=null)
|
---|
112 | {
|
---|
113 | parent::dot_base( 'hollow-dot', $value );
|
---|
114 | }
|
---|
115 | }
|
---|
116 |
|
---|
117 | /**
|
---|
118 | * Draw a star
|
---|
119 | */
|
---|
120 | class star extends dot_base
|
---|
121 | {
|
---|
122 | /**
|
---|
123 | * The constructor, takes an optional $value
|
---|
124 | */
|
---|
125 | function star($value=null)
|
---|
126 | {
|
---|
127 | parent::dot_base( 'star', $value );
|
---|
128 | }
|
---|
129 |
|
---|
130 | /**
|
---|
131 | * @param $angle is an integer.
|
---|
132 | */
|
---|
133 | function rotation($angle)
|
---|
134 | {
|
---|
135 | $this->rotation = $angle;
|
---|
136 | return $this;
|
---|
137 | }
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * @param $is_hollow is a boolean.
|
---|
141 | */
|
---|
142 | function hollow($is_hollow)
|
---|
143 | {
|
---|
144 | $this->hollow = $is_hollow;
|
---|
145 | }
|
---|
146 | }
|
---|
147 |
|
---|
148 | /**
|
---|
149 | * Draw a 'bow tie' shape.
|
---|
150 | */
|
---|
151 | class bow extends dot_base
|
---|
152 | {
|
---|
153 | /**
|
---|
154 | * The constructor, takes an optional $value
|
---|
155 | */
|
---|
156 | function bow($value=null)
|
---|
157 | {
|
---|
158 | parent::dot_base( 'bow', $value );
|
---|
159 | }
|
---|
160 |
|
---|
161 | /**
|
---|
162 | * Rotate the anchor object.
|
---|
163 | * @param $angle is an integer.
|
---|
164 | */
|
---|
165 | function rotation($angle)
|
---|
166 | {
|
---|
167 | $this->rotation = $angle;
|
---|
168 | return $this;
|
---|
169 | }
|
---|
170 | }
|
---|
171 |
|
---|
172 | /**
|
---|
173 | * An <i><b>n</b></i> sided shape.
|
---|
174 | */
|
---|
175 | class anchor extends dot_base
|
---|
176 | {
|
---|
177 | /**
|
---|
178 | * The constructor, takes an optional $value
|
---|
179 | */
|
---|
180 | function anchor($value=null)
|
---|
181 | {
|
---|
182 | parent::dot_base( 'anchor', $value );
|
---|
183 | }
|
---|
184 |
|
---|
185 | /**
|
---|
186 | * Rotate the anchor object.
|
---|
187 | * @param $angle is an integer.
|
---|
188 | */
|
---|
189 | function rotation($angle)
|
---|
190 | {
|
---|
191 | $this->rotation = $angle;
|
---|
192 | return $this;
|
---|
193 | }
|
---|
194 |
|
---|
195 | /**
|
---|
196 | * @param $sides is an integer. Number of sides this shape has.
|
---|
197 | */
|
---|
198 | function sides($sides)
|
---|
199 | {
|
---|
200 | $this->sides = $sides;
|
---|
201 | return $this;
|
---|
202 | }
|
---|
203 | }
|
---|
204 |
|
---|
205 | /**
|
---|
206 | * A simple dot
|
---|
207 | */
|
---|
208 | class dot extends dot_base
|
---|
209 | {
|
---|
210 | /**
|
---|
211 | * The constructor, takes an optional $value
|
---|
212 | */
|
---|
213 | function dot($value=null)
|
---|
214 | {
|
---|
215 | parent::dot_base( 'dot', $value );
|
---|
216 | }
|
---|
217 | }
|
---|
218 |
|
---|
219 | /**
|
---|
220 | * A simple dot
|
---|
221 | */
|
---|
222 | class solid_dot extends dot_base
|
---|
223 | {
|
---|
224 | /**
|
---|
225 | * The constructor, takes an optional $value
|
---|
226 | */
|
---|
227 | function solid_dot($value=null)
|
---|
228 | {
|
---|
229 | parent::dot_base( 'solid-dot', $value );
|
---|
230 | }
|
---|
231 | }
|
---|