@@ -13,341 +13,341 @@ |
||
13 | 13 | */ |
14 | 14 | class DataSet implements ChartOwnedInterface, ArraySerializableInterface, JsonSerializableInterface |
15 | 15 | { |
16 | - use ChartOwned; |
|
17 | - use Delegate\ArraySerializable; |
|
18 | - use Delegate\JsonSerializable; |
|
19 | - |
|
20 | - /** |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $type; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var Data |
|
27 | - */ |
|
28 | - protected $data; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - protected $label; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - protected $xAxisID; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
43 | - protected $yAxisID; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var string|string[] |
|
47 | - */ |
|
48 | - protected $backgroundColor; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var string|string[] |
|
52 | - */ |
|
53 | - protected $borderColor; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var int|int[] |
|
57 | - */ |
|
58 | - protected $borderWidth; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var string |
|
62 | - */ |
|
63 | - protected $borderSkipped; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var string|string[] |
|
67 | - */ |
|
68 | - protected $hoverBackgroundColor; |
|
69 | - |
|
70 | - /** |
|
71 | - * @var string|string[] |
|
72 | - */ |
|
73 | - protected $hoverBorderColor; |
|
74 | - |
|
75 | - /** |
|
76 | - * @var int|int[] |
|
77 | - */ |
|
78 | - protected $hoverBorderWidth; |
|
79 | - |
|
80 | - /** |
|
81 | - * @return string |
|
82 | - */ |
|
83 | - public function getType() |
|
84 | - { |
|
85 | - return $this->type; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @param string $type |
|
90 | - * |
|
91 | - * @return $this |
|
92 | - */ |
|
93 | - public function setType($type) |
|
94 | - { |
|
95 | - $this->type = $type; |
|
96 | - |
|
97 | - return $this; |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * @return Data |
|
102 | - */ |
|
103 | - public function data() |
|
104 | - { |
|
105 | - if (is_null($this->data)) { |
|
106 | - $this->data = new Data(); |
|
107 | - } |
|
108 | - |
|
109 | - return $this->data; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * @return string |
|
114 | - */ |
|
115 | - public function getLabel() |
|
116 | - { |
|
117 | - return $this->label; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * @param string $label |
|
122 | - * |
|
123 | - * @return $this |
|
124 | - */ |
|
125 | - public function setLabel($label) |
|
126 | - { |
|
127 | - $this->label = strval($label); |
|
128 | - |
|
129 | - return $this; |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * @return string |
|
134 | - */ |
|
135 | - public function getXAxisID() |
|
136 | - { |
|
137 | - return $this->xAxisID; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * @param string $xAxisID |
|
142 | - * |
|
143 | - * @return $this |
|
144 | - */ |
|
145 | - public function setXAxisID($xAxisID) |
|
146 | - { |
|
147 | - $this->xAxisID = strval($xAxisID); |
|
148 | - |
|
149 | - return $this; |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - public function getYAxisID() |
|
156 | - { |
|
157 | - return $this->yAxisID; |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * @param string $yAxisID |
|
162 | - * |
|
163 | - * @return $this |
|
164 | - */ |
|
165 | - public function setYAxisID($yAxisID) |
|
166 | - { |
|
167 | - $this->yAxisID = strval($yAxisID); |
|
168 | - |
|
169 | - return $this; |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * @return string|string[] |
|
174 | - */ |
|
175 | - public function getBackgroundColor() |
|
176 | - { |
|
177 | - return $this->backgroundColor; |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * @param string|string[] $backgroundColor |
|
182 | - * |
|
183 | - * @return $this |
|
184 | - */ |
|
185 | - public function setBackgroundColor($backgroundColor) |
|
186 | - { |
|
187 | - if (is_array($backgroundColor)) { |
|
188 | - $backgroundColor = array_map('strval', $backgroundColor); |
|
189 | - } |
|
190 | - if (! is_array($backgroundColor)) { |
|
191 | - $backgroundColor = strval($backgroundColor); |
|
192 | - } |
|
193 | - |
|
194 | - $this->backgroundColor = $backgroundColor; |
|
195 | - |
|
196 | - return $this; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * @return string|string[] |
|
201 | - */ |
|
202 | - public function getBorderColor() |
|
203 | - { |
|
204 | - return $this->borderColor; |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * @param string|string[] $borderColor |
|
209 | - * |
|
210 | - * @return $this |
|
211 | - */ |
|
212 | - public function setBorderColor($borderColor) |
|
213 | - { |
|
214 | - if (is_array($borderColor)) { |
|
215 | - $borderColor = array_map('strval', $borderColor); |
|
216 | - } |
|
217 | - if (! is_array($borderColor)) { |
|
218 | - $borderColor = strval($borderColor); |
|
219 | - } |
|
220 | - |
|
221 | - $this->borderColor = $borderColor; |
|
222 | - |
|
223 | - return $this; |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * @return int|int[] |
|
228 | - */ |
|
229 | - public function getBorderWidth() |
|
230 | - { |
|
231 | - return $this->borderWidth; |
|
232 | - } |
|
233 | - |
|
234 | - /** |
|
235 | - * @param int|int[] $borderWidth |
|
236 | - * |
|
237 | - * @return $this |
|
238 | - */ |
|
239 | - public function setBorderWidth($borderWidth) |
|
240 | - { |
|
241 | - if (is_array($borderWidth)) { |
|
242 | - $borderWidth = array_map('intval', $borderWidth); |
|
243 | - } |
|
244 | - if (! is_array($borderWidth)) { |
|
245 | - $borderWidth = intval($borderWidth); |
|
246 | - } |
|
247 | - |
|
248 | - $this->borderWidth = $borderWidth; |
|
249 | - |
|
250 | - return $this; |
|
251 | - } |
|
252 | - |
|
253 | - /** |
|
254 | - * @return string |
|
255 | - */ |
|
256 | - public function getBorderSkipped() |
|
257 | - { |
|
258 | - return $this->borderSkipped; |
|
259 | - } |
|
260 | - |
|
261 | - /** |
|
262 | - * @param string $borderSkipped |
|
263 | - * |
|
264 | - * @return $this |
|
265 | - */ |
|
266 | - public function setBorderSkipped($borderSkipped) |
|
267 | - { |
|
268 | - $this->borderSkipped = strval($borderSkipped); |
|
269 | - |
|
270 | - return $this; |
|
271 | - } |
|
272 | - |
|
273 | - /** |
|
274 | - * @return string|string[] |
|
275 | - */ |
|
276 | - public function getHoverBackgroundColor() |
|
277 | - { |
|
278 | - return $this->hoverBackgroundColor; |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * @param string|string[] $hoverBackgroundColor |
|
283 | - * |
|
284 | - * @return $this |
|
285 | - */ |
|
286 | - public function setHoverBackgroundColor($hoverBackgroundColor) |
|
287 | - { |
|
288 | - if (is_array($hoverBackgroundColor)) { |
|
289 | - $hoverBackgroundColor = array_map('strval', $hoverBackgroundColor); |
|
290 | - } |
|
291 | - if (! is_array($hoverBackgroundColor)) { |
|
292 | - $hoverBackgroundColor = strval($hoverBackgroundColor); |
|
293 | - } |
|
294 | - |
|
295 | - $this->hoverBackgroundColor = $hoverBackgroundColor; |
|
296 | - |
|
297 | - return $this; |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * @return string|string[] |
|
302 | - */ |
|
303 | - public function getHoverBorderColor() |
|
304 | - { |
|
305 | - return $this->hoverBorderColor; |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * @param string|string[] $hoverBorderColor |
|
310 | - * |
|
311 | - * @return $this |
|
312 | - */ |
|
313 | - public function setHoverBorderColor($hoverBorderColor) |
|
314 | - { |
|
315 | - if (is_array($hoverBorderColor)) { |
|
316 | - $hoverBorderColor = array_map('strval', $hoverBorderColor); |
|
317 | - } |
|
318 | - if (! is_array($hoverBorderColor)) { |
|
319 | - $hoverBorderColor = strval($hoverBorderColor); |
|
320 | - } |
|
321 | - |
|
322 | - $this->hoverBorderColor = $hoverBorderColor; |
|
323 | - |
|
324 | - return $this; |
|
325 | - } |
|
326 | - |
|
327 | - /** |
|
328 | - * @return int|int[] |
|
329 | - */ |
|
330 | - public function getHoverBorderWidth() |
|
331 | - { |
|
332 | - return $this->hoverBorderWidth; |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * @param int|int[] $hoverBorderWidth |
|
337 | - * |
|
338 | - * @return $this |
|
339 | - */ |
|
340 | - public function setHoverBorderWidth($hoverBorderWidth) |
|
341 | - { |
|
342 | - if (is_array($hoverBorderWidth)) { |
|
343 | - $hoverBorderWidth = array_map('intval', $hoverBorderWidth); |
|
344 | - } |
|
345 | - if (! is_array($hoverBorderWidth)) { |
|
346 | - $hoverBorderWidth = intval($hoverBorderWidth); |
|
347 | - } |
|
348 | - |
|
349 | - $this->hoverBorderWidth = $hoverBorderWidth; |
|
350 | - |
|
351 | - return $this; |
|
352 | - } |
|
16 | + use ChartOwned; |
|
17 | + use Delegate\ArraySerializable; |
|
18 | + use Delegate\JsonSerializable; |
|
19 | + |
|
20 | + /** |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $type; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var Data |
|
27 | + */ |
|
28 | + protected $data; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + protected $label; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + protected $xAxisID; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | + protected $yAxisID; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var string|string[] |
|
47 | + */ |
|
48 | + protected $backgroundColor; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var string|string[] |
|
52 | + */ |
|
53 | + protected $borderColor; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var int|int[] |
|
57 | + */ |
|
58 | + protected $borderWidth; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var string |
|
62 | + */ |
|
63 | + protected $borderSkipped; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var string|string[] |
|
67 | + */ |
|
68 | + protected $hoverBackgroundColor; |
|
69 | + |
|
70 | + /** |
|
71 | + * @var string|string[] |
|
72 | + */ |
|
73 | + protected $hoverBorderColor; |
|
74 | + |
|
75 | + /** |
|
76 | + * @var int|int[] |
|
77 | + */ |
|
78 | + protected $hoverBorderWidth; |
|
79 | + |
|
80 | + /** |
|
81 | + * @return string |
|
82 | + */ |
|
83 | + public function getType() |
|
84 | + { |
|
85 | + return $this->type; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @param string $type |
|
90 | + * |
|
91 | + * @return $this |
|
92 | + */ |
|
93 | + public function setType($type) |
|
94 | + { |
|
95 | + $this->type = $type; |
|
96 | + |
|
97 | + return $this; |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * @return Data |
|
102 | + */ |
|
103 | + public function data() |
|
104 | + { |
|
105 | + if (is_null($this->data)) { |
|
106 | + $this->data = new Data(); |
|
107 | + } |
|
108 | + |
|
109 | + return $this->data; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * @return string |
|
114 | + */ |
|
115 | + public function getLabel() |
|
116 | + { |
|
117 | + return $this->label; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * @param string $label |
|
122 | + * |
|
123 | + * @return $this |
|
124 | + */ |
|
125 | + public function setLabel($label) |
|
126 | + { |
|
127 | + $this->label = strval($label); |
|
128 | + |
|
129 | + return $this; |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * @return string |
|
134 | + */ |
|
135 | + public function getXAxisID() |
|
136 | + { |
|
137 | + return $this->xAxisID; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * @param string $xAxisID |
|
142 | + * |
|
143 | + * @return $this |
|
144 | + */ |
|
145 | + public function setXAxisID($xAxisID) |
|
146 | + { |
|
147 | + $this->xAxisID = strval($xAxisID); |
|
148 | + |
|
149 | + return $this; |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + public function getYAxisID() |
|
156 | + { |
|
157 | + return $this->yAxisID; |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * @param string $yAxisID |
|
162 | + * |
|
163 | + * @return $this |
|
164 | + */ |
|
165 | + public function setYAxisID($yAxisID) |
|
166 | + { |
|
167 | + $this->yAxisID = strval($yAxisID); |
|
168 | + |
|
169 | + return $this; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * @return string|string[] |
|
174 | + */ |
|
175 | + public function getBackgroundColor() |
|
176 | + { |
|
177 | + return $this->backgroundColor; |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * @param string|string[] $backgroundColor |
|
182 | + * |
|
183 | + * @return $this |
|
184 | + */ |
|
185 | + public function setBackgroundColor($backgroundColor) |
|
186 | + { |
|
187 | + if (is_array($backgroundColor)) { |
|
188 | + $backgroundColor = array_map('strval', $backgroundColor); |
|
189 | + } |
|
190 | + if (! is_array($backgroundColor)) { |
|
191 | + $backgroundColor = strval($backgroundColor); |
|
192 | + } |
|
193 | + |
|
194 | + $this->backgroundColor = $backgroundColor; |
|
195 | + |
|
196 | + return $this; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * @return string|string[] |
|
201 | + */ |
|
202 | + public function getBorderColor() |
|
203 | + { |
|
204 | + return $this->borderColor; |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * @param string|string[] $borderColor |
|
209 | + * |
|
210 | + * @return $this |
|
211 | + */ |
|
212 | + public function setBorderColor($borderColor) |
|
213 | + { |
|
214 | + if (is_array($borderColor)) { |
|
215 | + $borderColor = array_map('strval', $borderColor); |
|
216 | + } |
|
217 | + if (! is_array($borderColor)) { |
|
218 | + $borderColor = strval($borderColor); |
|
219 | + } |
|
220 | + |
|
221 | + $this->borderColor = $borderColor; |
|
222 | + |
|
223 | + return $this; |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * @return int|int[] |
|
228 | + */ |
|
229 | + public function getBorderWidth() |
|
230 | + { |
|
231 | + return $this->borderWidth; |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * @param int|int[] $borderWidth |
|
236 | + * |
|
237 | + * @return $this |
|
238 | + */ |
|
239 | + public function setBorderWidth($borderWidth) |
|
240 | + { |
|
241 | + if (is_array($borderWidth)) { |
|
242 | + $borderWidth = array_map('intval', $borderWidth); |
|
243 | + } |
|
244 | + if (! is_array($borderWidth)) { |
|
245 | + $borderWidth = intval($borderWidth); |
|
246 | + } |
|
247 | + |
|
248 | + $this->borderWidth = $borderWidth; |
|
249 | + |
|
250 | + return $this; |
|
251 | + } |
|
252 | + |
|
253 | + /** |
|
254 | + * @return string |
|
255 | + */ |
|
256 | + public function getBorderSkipped() |
|
257 | + { |
|
258 | + return $this->borderSkipped; |
|
259 | + } |
|
260 | + |
|
261 | + /** |
|
262 | + * @param string $borderSkipped |
|
263 | + * |
|
264 | + * @return $this |
|
265 | + */ |
|
266 | + public function setBorderSkipped($borderSkipped) |
|
267 | + { |
|
268 | + $this->borderSkipped = strval($borderSkipped); |
|
269 | + |
|
270 | + return $this; |
|
271 | + } |
|
272 | + |
|
273 | + /** |
|
274 | + * @return string|string[] |
|
275 | + */ |
|
276 | + public function getHoverBackgroundColor() |
|
277 | + { |
|
278 | + return $this->hoverBackgroundColor; |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * @param string|string[] $hoverBackgroundColor |
|
283 | + * |
|
284 | + * @return $this |
|
285 | + */ |
|
286 | + public function setHoverBackgroundColor($hoverBackgroundColor) |
|
287 | + { |
|
288 | + if (is_array($hoverBackgroundColor)) { |
|
289 | + $hoverBackgroundColor = array_map('strval', $hoverBackgroundColor); |
|
290 | + } |
|
291 | + if (! is_array($hoverBackgroundColor)) { |
|
292 | + $hoverBackgroundColor = strval($hoverBackgroundColor); |
|
293 | + } |
|
294 | + |
|
295 | + $this->hoverBackgroundColor = $hoverBackgroundColor; |
|
296 | + |
|
297 | + return $this; |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * @return string|string[] |
|
302 | + */ |
|
303 | + public function getHoverBorderColor() |
|
304 | + { |
|
305 | + return $this->hoverBorderColor; |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * @param string|string[] $hoverBorderColor |
|
310 | + * |
|
311 | + * @return $this |
|
312 | + */ |
|
313 | + public function setHoverBorderColor($hoverBorderColor) |
|
314 | + { |
|
315 | + if (is_array($hoverBorderColor)) { |
|
316 | + $hoverBorderColor = array_map('strval', $hoverBorderColor); |
|
317 | + } |
|
318 | + if (! is_array($hoverBorderColor)) { |
|
319 | + $hoverBorderColor = strval($hoverBorderColor); |
|
320 | + } |
|
321 | + |
|
322 | + $this->hoverBorderColor = $hoverBorderColor; |
|
323 | + |
|
324 | + return $this; |
|
325 | + } |
|
326 | + |
|
327 | + /** |
|
328 | + * @return int|int[] |
|
329 | + */ |
|
330 | + public function getHoverBorderWidth() |
|
331 | + { |
|
332 | + return $this->hoverBorderWidth; |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * @param int|int[] $hoverBorderWidth |
|
337 | + * |
|
338 | + * @return $this |
|
339 | + */ |
|
340 | + public function setHoverBorderWidth($hoverBorderWidth) |
|
341 | + { |
|
342 | + if (is_array($hoverBorderWidth)) { |
|
343 | + $hoverBorderWidth = array_map('intval', $hoverBorderWidth); |
|
344 | + } |
|
345 | + if (! is_array($hoverBorderWidth)) { |
|
346 | + $hoverBorderWidth = intval($hoverBorderWidth); |
|
347 | + } |
|
348 | + |
|
349 | + $this->hoverBorderWidth = $hoverBorderWidth; |
|
350 | + |
|
351 | + return $this; |
|
352 | + } |
|
353 | 353 | } |
@@ -12,31 +12,31 @@ |
||
12 | 12 | */ |
13 | 13 | class DataSetCollection extends ArrayAccess implements JsonSerializable |
14 | 14 | { |
15 | - /** |
|
16 | - * @return array |
|
17 | - */ |
|
18 | - public function getArrayCopy() |
|
19 | - { |
|
20 | - $rows = []; |
|
21 | - foreach ($this->data as $row) { |
|
22 | - /** @var DataSet $row */ |
|
23 | - $rows[] = $row->getArrayCopy(); |
|
24 | - } |
|
15 | + /** |
|
16 | + * @return array |
|
17 | + */ |
|
18 | + public function getArrayCopy() |
|
19 | + { |
|
20 | + $rows = []; |
|
21 | + foreach ($this->data as $row) { |
|
22 | + /** @var DataSet $row */ |
|
23 | + $rows[] = $row->getArrayCopy(); |
|
24 | + } |
|
25 | 25 | |
26 | - return $rows; |
|
27 | - } |
|
26 | + return $rows; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * @return array |
|
31 | - */ |
|
32 | - public function jsonSerialize() |
|
33 | - { |
|
34 | - $rows = []; |
|
35 | - foreach ($this->data as $row) { |
|
36 | - /** @var DataSet $row */ |
|
37 | - $rows[] = $row->jsonSerialize(); |
|
38 | - } |
|
29 | + /** |
|
30 | + * @return array |
|
31 | + */ |
|
32 | + public function jsonSerialize() |
|
33 | + { |
|
34 | + $rows = []; |
|
35 | + foreach ($this->data as $row) { |
|
36 | + /** @var DataSet $row */ |
|
37 | + $rows[] = $row->jsonSerialize(); |
|
38 | + } |
|
39 | 39 | |
40 | - return $rows; |
|
41 | - } |
|
40 | + return $rows; |
|
41 | + } |
|
42 | 42 | } |
@@ -12,19 +12,19 @@ |
||
12 | 12 | */ |
13 | 13 | trait JsonSerializable |
14 | 14 | { |
15 | - /** |
|
16 | - * @return array |
|
17 | - */ |
|
18 | - public function jsonSerialize() |
|
19 | - { |
|
20 | - return array_map(function ($value) { |
|
21 | - if ($value instanceof JsonSerializableInterface) { |
|
22 | - return $value->jsonSerialize(); |
|
23 | - } elseif ($value instanceof ArraySerializableInterface) { |
|
24 | - return $value->getArrayCopy(); |
|
25 | - } |
|
15 | + /** |
|
16 | + * @return array |
|
17 | + */ |
|
18 | + public function jsonSerialize() |
|
19 | + { |
|
20 | + return array_map(function ($value) { |
|
21 | + if ($value instanceof JsonSerializableInterface) { |
|
22 | + return $value->jsonSerialize(); |
|
23 | + } elseif ($value instanceof ArraySerializableInterface) { |
|
24 | + return $value->getArrayCopy(); |
|
25 | + } |
|
26 | 26 | |
27 | - return $value; |
|
28 | - }, $this->getArrayCopy()); |
|
29 | - } |
|
27 | + return $value; |
|
28 | + }, $this->getArrayCopy()); |
|
29 | + } |
|
30 | 30 | } |
@@ -11,26 +11,26 @@ |
||
11 | 11 | */ |
12 | 12 | trait ArraySerializable |
13 | 13 | { |
14 | - /** |
|
15 | - * Returns an array copy of the properties and their current values in this class |
|
16 | - * |
|
17 | - * @return array |
|
18 | - */ |
|
19 | - public function getArrayCopy() |
|
20 | - { |
|
21 | - $currentValues = array_map(function ($value) { |
|
22 | - if (is_object($value)) { |
|
23 | - if ($value instanceof ArraySerializableInterface) { |
|
24 | - return $value->getArrayCopy(); |
|
25 | - } |
|
26 | - } |
|
14 | + /** |
|
15 | + * Returns an array copy of the properties and their current values in this class |
|
16 | + * |
|
17 | + * @return array |
|
18 | + */ |
|
19 | + public function getArrayCopy() |
|
20 | + { |
|
21 | + $currentValues = array_map(function ($value) { |
|
22 | + if (is_object($value)) { |
|
23 | + if ($value instanceof ArraySerializableInterface) { |
|
24 | + return $value->getArrayCopy(); |
|
25 | + } |
|
26 | + } |
|
27 | 27 | |
28 | - return $value; |
|
29 | - }, get_object_vars($this)); |
|
28 | + return $value; |
|
29 | + }, get_object_vars($this)); |
|
30 | 30 | |
31 | - // Filter out null values and return the remaining. |
|
32 | - return array_filter($currentValues, function ($value, $key) { |
|
33 | - return ! is_null($value) && $key !== 'owner'; |
|
34 | - }, ARRAY_FILTER_USE_BOTH); |
|
35 | - } |
|
31 | + // Filter out null values and return the remaining. |
|
32 | + return array_filter($currentValues, function ($value, $key) { |
|
33 | + return ! is_null($value) && $key !== 'owner'; |
|
34 | + }, ARRAY_FILTER_USE_BOTH); |
|
35 | + } |
|
36 | 36 | } |
@@ -11,40 +11,40 @@ |
||
11 | 11 | */ |
12 | 12 | class Json extends Renderer |
13 | 13 | { |
14 | - /** |
|
15 | - * Render the necessary JSON for the chart to function in the frontend. |
|
16 | - * |
|
17 | - * @param int|false $flags |
|
18 | - * |
|
19 | - * @return string |
|
20 | - */ |
|
21 | - public function render($flags = null) |
|
22 | - { |
|
23 | - $config = [ |
|
24 | - 'type' => constant(get_class($this->chart) . "::TYPE"), |
|
25 | - 'data' => [], |
|
26 | - ]; |
|
27 | - |
|
28 | - $labels = $this->chart->labels()->jsonSerialize(); |
|
29 | - if ($labels) { |
|
30 | - $config['data']['labels'] = $labels; |
|
31 | - } |
|
32 | - |
|
33 | - $dataSets = $this->chart->dataSets()->jsonSerialize(); |
|
34 | - if ($dataSets) { |
|
35 | - $config['data']['datasets'] = $dataSets; |
|
36 | - } |
|
37 | - |
|
38 | - $options = $this->chart->options()->jsonSerialize(); |
|
39 | - if (! empty($options)) { |
|
40 | - $config['options'] = $options; |
|
41 | - } |
|
42 | - |
|
43 | - $output = JsonHelper::encode($config, false, ['enableJsonExprFinder' => true]); |
|
44 | - if ($flags & Renderer::RENDER_PRETTY) { |
|
45 | - $output = JsonHelper::prettyPrint($output); |
|
46 | - } |
|
47 | - |
|
48 | - return $output; |
|
49 | - } |
|
14 | + /** |
|
15 | + * Render the necessary JSON for the chart to function in the frontend. |
|
16 | + * |
|
17 | + * @param int|false $flags |
|
18 | + * |
|
19 | + * @return string |
|
20 | + */ |
|
21 | + public function render($flags = null) |
|
22 | + { |
|
23 | + $config = [ |
|
24 | + 'type' => constant(get_class($this->chart) . "::TYPE"), |
|
25 | + 'data' => [], |
|
26 | + ]; |
|
27 | + |
|
28 | + $labels = $this->chart->labels()->jsonSerialize(); |
|
29 | + if ($labels) { |
|
30 | + $config['data']['labels'] = $labels; |
|
31 | + } |
|
32 | + |
|
33 | + $dataSets = $this->chart->dataSets()->jsonSerialize(); |
|
34 | + if ($dataSets) { |
|
35 | + $config['data']['datasets'] = $dataSets; |
|
36 | + } |
|
37 | + |
|
38 | + $options = $this->chart->options()->jsonSerialize(); |
|
39 | + if (! empty($options)) { |
|
40 | + $config['options'] = $options; |
|
41 | + } |
|
42 | + |
|
43 | + $output = JsonHelper::encode($config, false, ['enableJsonExprFinder' => true]); |
|
44 | + if ($flags & Renderer::RENDER_PRETTY) { |
|
45 | + $output = JsonHelper::prettyPrint($output); |
|
46 | + } |
|
47 | + |
|
48 | + return $output; |
|
49 | + } |
|
50 | 50 | } |
@@ -9,28 +9,28 @@ discard block |
||
9 | 9 | */ |
10 | 10 | class JavaScript extends Renderer |
11 | 11 | { |
12 | - /** |
|
13 | - * Renders the necessary JavaScript for the chart to function in the frontend. |
|
14 | - * |
|
15 | - * @param int|null $flags |
|
16 | - * |
|
17 | - * @return string |
|
18 | - */ |
|
19 | - public function render($flags = null) |
|
20 | - { |
|
21 | - $script = []; |
|
12 | + /** |
|
13 | + * Renders the necessary JavaScript for the chart to function in the frontend. |
|
14 | + * |
|
15 | + * @param int|null $flags |
|
16 | + * |
|
17 | + * @return string |
|
18 | + */ |
|
19 | + public function render($flags = null) |
|
20 | + { |
|
21 | + $script = []; |
|
22 | 22 | |
23 | - // First, setup the canvas context |
|
24 | - $script[] = "var ctx = document.getElementById( \"{$this->chart->getId()}\" ).getContext( \"2d\" );"; |
|
23 | + // First, setup the canvas context |
|
24 | + $script[] = "var ctx = document.getElementById( \"{$this->chart->getId()}\" ).getContext( \"2d\" );"; |
|
25 | 25 | |
26 | - // Now, setup the chart instance |
|
27 | - $jsonRenderer = new Json($this->chart); |
|
28 | - $json = $jsonRenderer->render($flags); |
|
29 | - $script[] = "var chart = new Chart( ctx, {$json} );"; |
|
30 | - $scriptString = implode("\n", $script); |
|
26 | + // Now, setup the chart instance |
|
27 | + $jsonRenderer = new Json($this->chart); |
|
28 | + $json = $jsonRenderer->render($flags); |
|
29 | + $script[] = "var chart = new Chart( ctx, {$json} );"; |
|
30 | + $scriptString = implode("\n", $script); |
|
31 | 31 | |
32 | - // Return the script |
|
33 | - return <<<JS |
|
32 | + // Return the script |
|
33 | + return <<<JS |
|
34 | 34 | window.onload=(function(oldLoad){return function(){ |
35 | 35 | if (oldLoad) { |
36 | 36 | oldLoad(); |
@@ -45,6 +45,6 @@ discard block |
||
45 | 45 | window.chartInstances['{$this->chart->getId()}'] = chart; |
46 | 46 | }})(window.onload); |
47 | 47 | JS |
48 | - ; |
|
49 | - } |
|
48 | + ; |
|
49 | + } |
|
50 | 50 | } |
@@ -13,5 +13,5 @@ |
||
13 | 13 | */ |
14 | 14 | class Data extends ArrayAccess implements JsonSerializableInterface |
15 | 15 | { |
16 | - use Delegate\JsonSerializable; |
|
16 | + use Delegate\JsonSerializable; |
|
17 | 17 | } |