PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.2.0
GiveWP – Donation Plugin and Fundraising Platform v2.2.0
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 / markers / GoogleChartShapeMarker.php
give / includes / libraries / googlechartlib / markers Last commit date
GoogleChartCandlestickMarker.php 8 years ago GoogleChartLineMarker.php 8 years ago GoogleChartRangeMarker.php 8 years ago GoogleChartShapeMarker.php 8 years ago GoogleChartTextMarker.php 8 years ago
GoogleChartShapeMarker.php
234 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 require_once dirname(__FILE__).'/../GoogleChartMarker.php';
14
15 /**
16 * A Shape Marker.
17 *
18 * This class implement the Shape Marker feature (@c chm)
19 *
20 * @par Example
21 * @include marker_shape.php
22 *
23 * @see http://code.google.com/apis/chart/docs/chart_params.html#gcharts_shape_markers
24 */
25 class GoogleChartShapeMarker extends GoogleChartMarker
26 {
27 const ARROW = 'a';
28 const CROSS = 'c';
29 //~ const RECTANGLE = 'C';
30 const DIAMOND = 'd';
31 //~ const ERROR_BAR = 'E';
32 const CIRCLE = 'o';
33 const SQUARE = 's';
34 const X = 'x';
35
36 protected $shape = null;
37
38 protected $points = null;
39 protected $position = null;
40
41 protected $size = '10';
42
43 protected $border = null;
44
45 /**
46 * Constructor.
47 *
48 * @see http://code.google.com/apis/chart/docs/chart_params.html#gcharts_shape_markers
49 * @param $shape You can specify the shape of the marker.
50 */
51 public function __construct($shape = self::CIRCLE)
52 {
53 $this->shape = $shape;
54 }
55
56 /**
57 * @name Position
58 * Thoses functions are mutually exclusive (if you call more than one of them,
59 * only the last one will be remembered).
60 */
61 //@{
62 /**
63 * Set a fixed position for the marker.
64 *
65 * When a marker has a fixed position, you MUST NOT associate it to a data
66 * serie (with setData()). Otherwise, the fixed position will be ignored.
67 *
68 * @param $x (float) between 0 and 1
69 * @param $y (float) between 0 and 1
70 * @return $this
71 */
72 public function setFixedPosition($x, $y)
73 {
74 if ( $x < 0 || $x > 1 || ! is_numeric($x) )
75 throw new InvalidArgumentException('Invalid x position (must be between 0 and 1)');
76 if ( $y < 0 || $y > 1 || ! is_numeric($y) )
77 throw new InvalidArgumentException('Invalid y position (must be between 0 and 1)');
78
79 $this->position = array(
80 'x' => $x,
81 'y' => $y
82 );
83 return $this;
84 }
85
86 /**
87 * Displays only the selected point.
88 *
89 * @param $point (int) The index of the point to display (0 based) in the data serie
90 * @return $this
91 */
92 public function setPoint($point)
93 {
94 $this->points = $point;
95 return $this;
96 }
97
98 /**
99 * Displays a range of points (@c start:end:n or @c -n format).
100 *
101 * @return $this
102 */
103 public function setPoints($start = null, $end = null, $step = null)
104 {
105 if ( $this->points['start'] === null && $this->points['end'] === null && $this->points['step'] === null ) {
106 $this->points = null;
107 }
108
109 $this->points = array(
110 'start' => $start,
111 'end' => $end,
112 'step' => $step
113 );
114 return $this;
115 }
116
117 /**
118 * Displays every nth points (@c -n format).
119 *
120 * @return $this
121 */
122 public function setStep($step)
123 {
124 $this->points = array(
125 'start' => null,
126 'end' => null,
127 'step' => $step
128 );
129 return $this;
130 }
131 //@}
132
133 /**
134 * Set the size of the shape.
135 *
136 * @param $size (int)
137 * @return $this
138 */
139 public function setSize($size)
140 {
141 $this->size = $size;
142 return $this;
143 }
144
145 /**
146 * Set a border to the shape.
147 *
148 * To create a border to a shape with Google Chart API, you need to create
149 * another similar marker below the first one, with a different color
150 * and a slightly bigger size.
151 *
152 * This function does the job for you. Just specify a color and the size of
153 * the border, and it will create the second marker automatically.
154 *
155 * @since 0.4
156 *
157 * @param $size (int) size of the border (default is 2)
158 * @param $color (string) a color in RRGGBB format (default is white)
159 * @return $this
160 */
161 public function setBorder($size = 2, $color = 'ffffff')
162 {
163 $this->border = array(
164 'size' => $size,
165 'color' => $color
166 );
167 return $this;
168 }
169
170 /**
171 * @internal
172 */
173 public function compute($index, $chart_type = null)
174 {
175 if ( $index === null ) {
176 if ( $this->position === null ) {
177 throw new LogicException('Shape marker requires one data serie or requires to have a fixed position.');
178 }
179
180 // Fixed position marker (x:y format)
181 $str = '@';
182 $points = $this->position['x'].':'.$this->position['y'];
183 }
184 else {
185 $str = '';
186 // Default = all (-1 format)
187 if ( $this->points === null ) {
188 $points = '-1';
189 }
190 // Only one point (n.d format)
191 elseif ( ! is_array($this->points) ) {
192 $points = number_format($this->points,1);
193 }
194 // Step only (-n format)
195 elseif ( $this->points['start'] === null && $this->points['end'] === null ) {
196 $points = '-'.$this->points['step'];
197 }
198 // Serie (start:end:n)
199 else {
200 $points = $this->points['start'].':'.$this->points['end'].':'.$this->points['step'];
201 }
202 }
203
204 if ( $this->border !== null ) {
205 $str .= sprintf(
206 '%s,%s,%d,%s,%s|',
207 $this->shape,
208 $this->border['color'],
209 $index,
210 $points,
211 $this->size + $this->border['size']
212 );
213 }
214
215 $str .= sprintf(
216 '%s,%s,%d,%s,%s',
217 $this->shape,
218 $this->color,
219 $index,
220 $points,
221 $this->size
222 );
223
224 if ( $this->z_order !== null ) {
225 $str .= ','.$this->z_order;
226 }
227 return $str;
228 }
229 }
230
231 /** @example marker_shape_fixed_position.php
232 * An example of a shape marker with fixed position
233 */
234