PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.23.2
GiveWP – Donation Plugin and Fundraising Platform v2.23.2
4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / libraries / googlechartlib / GoogleChartAxis.php
give / includes / libraries / googlechartlib Last commit date
icons 8 years ago markers 8 years ago GoogleChart.php 8 years ago GoogleChartApi.php 8 years ago GoogleChartAxis.php 8 years ago GoogleChartData.php 8 years ago GoogleChartIcon.php 8 years ago GoogleChartMarker.php 8 years ago LICENSE 8 years ago
GoogleChartAxis.php
330 lines
1 <?php
2
3 /** @file
4 * This file is part of Google Chart PHP library.
5 *
6 * Copyright (c) 2010 Rémi Lanvin <remi@cloudconnected.fr>
7 *
8 * Licensed under the MIT license.
9 *
10 * For the full copyright and license information, please view the LICENSE file.
11 */
12
13 /**
14 * An Axis.
15 */
16 class GoogleChartAxis
17 {
18 const ALIGN_LEFT = -1;
19 const ALIGN_CENTER = 0;
20 const ALIGN_RIGHT = 1;
21
22 /**
23 * @var string Name of the axis
24 */
25 protected $name = null;
26 /**
27 * @var array
28 */
29 protected $labels = null;
30
31 protected $range = null;
32 protected $tick_marks = null;
33 protected $style = null;
34
35 protected $chxs = 0;
36 protected $label_color = '666666';
37 protected $font_size = '11';
38 protected $label_alignment = null;
39 protected $draw_line = true;
40 protected $draw_tick_marks = true;
41 protected $tick_color = '666666';
42 protected $label_positions = null;
43
44 /**
45 * Create a new axis.
46 *
47 * @param string $name The name of the axis. Supported axis are 'x', 'y', 't' (top) or 'r' (right).
48 */
49 public function __construct($name)
50 {
51 switch ( $name ) {
52 case 'x':
53 case 't':
54 $this->label_alignment = 0;
55 break;
56 case 'r':
57 $this->label_alignment = -1;
58 break;
59 case 'y':
60 $this->label_alignment = 1;
61 break;
62 default:
63 throw new InvalidArgumentException('Axis names must be x, y, t or r.');
64 }
65
66 $this->name = $name;
67 }
68
69 /**
70 * Returns the name.
71 *
72 * @return string
73 */
74 public function getName()
75 {
76 return $this->name;
77 }
78
79 /**
80 * Custom axis labels (chxl).
81 *
82 * @see http://code.google.com/apis/chart/docs/chart_params.html#axis_labels
83 */
84 public function setLabels(array $labels)
85 {
86 $this->labels = $labels;
87 return $this;
88 }
89
90 public function getLabels($compute = true)
91 {
92 if ( ! $compute ) {
93 return $this->labels;
94 }
95
96 if ( $this->labels === null )
97 return null;
98
99 return '%d:|'.implode('|',$this->labels);
100 }
101
102 public function hasCustomLabels()
103 {
104 return $this->labels !== null;
105 }
106
107 /**
108 * Axis ranges (chxr).
109 *
110 * Specify the range of values that appear.
111 *
112 * @see http://code.google.com/apis/chart/docs/chart_params.html#axis_range
113 */
114 public function setRange($start_val, $end_val, $step = false)
115 {
116 $this->range = array(
117 'start_val' => $start_val === null ? 0 : $start_val,
118 'end_val' => $end_val === null ? 100 : $end_val,
119 'step' => $step === null ? false : $step
120 );
121 return $this;
122 }
123
124 public function getRange($compute = true)
125 {
126 if ( ! $compute )
127 return $this->range;
128
129 if ( $this->range === null )
130 return null;
131
132 $str = '%d,'.$this->range['start_val'].','.$this->range['end_val'];
133 if ( $this->range['step'] !== false )
134 $str .= ','.$this->range['step'];
135 return $str;
136 }
137
138 /**
139 * Axis Tick Mark Styles (chxtc)
140 *
141 * @see http://code.google.com/apis/chart/docs/chart_params.html#axis_tick_marks
142 */
143 public function setTickMarks()
144 {
145 $this->tick_marks = func_get_args();
146 if ( ! isset($this->tick_marks[0]) )
147 $this->tick_marks = null;
148
149 return $this;
150 }
151
152 public function getTickMarks($compute = true)
153 {
154 if ( ! $compute )
155 return $this->tick_marks;
156
157 if ( $this->tick_marks === null )
158 return null;
159
160 return '%d,'.implode(',',$this->tick_marks);
161 }
162
163 /**
164 * @c chxp
165 */
166 public function setLabelPositions()
167 {
168 $this->label_positions = func_get_args();
169 if ( ! isset($this->label_positions[0]) )
170 $this->label_positions = null;
171
172 return $this;
173 }
174
175 public function computeChxp($axis_index)
176 {
177 if ( ! $this->label_positions )
178 return null;
179
180 $str = $axis_index.','.implode(',',$this->label_positions);
181 return $str;
182 }
183
184 public function hasChxp()
185 {
186 return $this->label_positions !== null;
187 }
188
189 /**
190 * @name Axis style (chxs)
191 */
192 //@{
193
194 /**
195 * @since 0.4
196 */
197 public function setLabelFormat()
198 {
199 if ( $this->chxs < 1 ) {
200 $this->chxs = 1;
201 }
202
203 // @todo
204
205 return $this;
206 }
207
208 /**
209 * @since 0.4
210 */
211 public function setLabelColor($color)
212 {
213 if ( $this->chxs < 1 ) {
214 $this->chxs = 1;
215 }
216 $this->label_color = $color;
217 return $this;
218 }
219
220 /**
221 * @since 0.4
222 */
223 public function setFontSize($size)
224 {
225 if ( $this->chxs < 2 ) {
226 $this->chxs = 2;
227 }
228 $this->font_size = $size;
229 return $this;
230 }
231
232 /**
233 * @since 0.4
234 */
235 public function setLabelAlignment($alignment)
236 {
237 if ( $this->chxs < 3 ) {
238 $this->chxs = 3;
239 }
240 $this->label_alignment = $alignment;
241 return $this;
242 }
243
244 /**
245 * @since 0.4
246 */
247 public function setDrawLine($line)
248 {
249 if ( $this->chxs < 4 ) {
250 $this->chxs = 4;
251 }
252 $this->draw_line = $line;
253 return $this;
254 }
255
256 /**
257 * @since 0.4
258 */
259 public function setDrawTickMarks($tick_marks)
260 {
261 if ( $this->chxs < 4 ) {
262 $this->chxs = 4;
263 }
264 $this->draw_tick_marks = $tick_marks;
265 return $this;
266 }
267
268 /**
269 * @since 0.4
270 */
271 public function setTickColor($tick_color)
272 {
273 if ( $this->chxs < 5 ) {
274 $this->chxs = 5;
275 }
276 $this->tick_color = $tick_color;
277 return $this;
278 }
279
280 /**
281 * @since 0.5
282 */
283 public function computeChxs($axis_index, $chart_type = null)
284 {
285 // Parameter not needed for this axis
286 if ( ! $this->chxs )
287 return null;
288
289 // Axis index (provided by GoogleChart class at runtime)
290 $str = $axis_index;
291
292 // @todo format string
293
294 $str .= ','.$this->label_color;
295 if ( $this->chxs > 1 ) {
296 $str .= ','.$this->font_size;
297 if ( $this->chxs > 2 ) {
298 $str .= ','.$this->label_alignment;
299 if ( $this->chxs > 3 ) {
300 $str .= ',';
301 if ( ! $this->draw_line && ! $this->draw_tick_marks ) {
302 $str .= '_';
303 }
304 else {
305 if ( $this->draw_line ) {
306 $str .= 'l';
307 }
308 if ( $this->draw_tick_marks ) {
309 $str .= 't';
310 }
311 }
312
313 // Not supported in Google-o-meter
314 if ( $this->chxs > 4 && $chart_type != 'gom') {
315 $str .= ','.$this->tick_color;
316 }
317 }
318 }
319 }
320
321 return $str;
322 }
323
324 public function getLabelFormat($compute = true)
325 {
326
327 }
328 //@}
329 }
330