1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Halfpastfour\PHPChartJS\Options\Elements; |
4
|
|
|
|
5
|
|
|
use Halfpastfour\PHPChartJS\ArraySerializableInterface; |
6
|
|
|
use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; |
7
|
|
|
use Zend\Json\Json; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class Point |
11
|
|
|
* @package Halfpastfour\PHPChartJS\Options\Elements |
12
|
|
|
*/ |
13
|
|
|
class Point implements ArraySerializableInterface, \JsonSerializable |
14
|
|
|
{ |
15
|
|
|
use ArraySerializable; |
16
|
|
|
|
17
|
|
|
const STYLE_CIRCLE = 'circle'; |
18
|
|
|
const STYLE_CROSS = 'cross'; |
19
|
|
|
const STYLE_CROSS_ROT = 'crossRot'; |
20
|
|
|
const STYLE_DASH = 'dash'; |
21
|
|
|
const STYLE_LINE = 'line'; |
22
|
|
|
const STYLE_RECT = 'rect'; |
23
|
|
|
const STYLE_RECT_ROUNDED = 'rectRounded'; |
24
|
|
|
const STYLE_RECT_ROT = 'rectRot'; |
25
|
|
|
const STYLE_RECT_STAR = 'star'; |
26
|
|
|
const STYLE_TRIANGLE = 'triangle'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Point radius. |
30
|
|
|
* @default 3 |
31
|
|
|
* @var int |
32
|
|
|
*/ |
33
|
|
|
private $radius; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Point style. |
37
|
|
|
* @default self::STYLE_CIRCLE |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
private $pointStyle; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Point rotation (in degrees). |
44
|
|
|
* @default 0 |
45
|
|
|
* @var int |
46
|
|
|
*/ |
47
|
|
|
private $rotation; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Point fill color. |
51
|
|
|
* @default 'rgba(0,0,0,0.1)' |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
private $backgroundColor; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Point stroke width. |
58
|
|
|
* @default 1 |
59
|
|
|
* @var int |
60
|
|
|
*/ |
61
|
|
|
private $borderWidth; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Point stroke color. |
65
|
|
|
* @default 'rgba(0,0,0,0.1)' |
66
|
|
|
* @var string |
67
|
|
|
*/ |
68
|
|
|
private $borderColor; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Extra radius added to point radius for hit detection. |
72
|
|
|
* @default 1 |
73
|
|
|
* @var int |
74
|
|
|
*/ |
75
|
|
|
private $hitRadius; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Point radius when hovered. |
79
|
|
|
* @default 4 |
80
|
|
|
* @var int |
81
|
|
|
*/ |
82
|
|
|
private $hoverRadius; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Stroke width when hovered. |
86
|
|
|
* @default 1 |
87
|
|
|
* @var int |
88
|
|
|
*/ |
89
|
|
|
private $hoverBorderWidth; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return int |
93
|
|
|
*/ |
94
|
|
|
public function getRadius() |
95
|
|
|
{ |
96
|
|
|
return $this->radius; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param int $radius |
101
|
|
|
* @return Point |
102
|
|
|
*/ |
103
|
|
|
public function setRadius($radius) |
104
|
|
|
{ |
105
|
|
|
$this->radius = intval($radius); |
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return string |
111
|
|
|
*/ |
112
|
|
|
public function getPointStyle() |
113
|
|
|
{ |
114
|
|
|
return $this->pointStyle; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @param string $pointStyle |
119
|
|
|
* @return Point |
120
|
|
|
*/ |
121
|
|
|
public function setPointStyle($pointStyle) |
122
|
|
|
{ |
123
|
|
|
$this->pointStyle = is_null($pointStyle) ? null : strval($pointStyle); |
|
|
|
|
124
|
|
|
return $this; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return int |
129
|
|
|
*/ |
130
|
|
|
public function getRotation() |
131
|
|
|
{ |
132
|
|
|
return $this->rotation; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @param int $rotation |
137
|
|
|
* @return Point |
138
|
|
|
*/ |
139
|
|
|
public function setRotation($rotation) |
140
|
|
|
{ |
141
|
|
|
$this->rotation = intval($rotation); |
142
|
|
|
return $this; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return string |
147
|
|
|
*/ |
148
|
|
|
public function getBackgroundColor() |
149
|
|
|
{ |
150
|
|
|
return $this->backgroundColor; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @param string $backgroundColor |
155
|
|
|
* @return Point |
156
|
|
|
*/ |
157
|
|
|
public function setBackgroundColor($backgroundColor) |
158
|
|
|
{ |
159
|
|
|
$this->backgroundColor = is_null($backgroundColor) ? null : strval($backgroundColor); |
|
|
|
|
160
|
|
|
return $this; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @return int |
165
|
|
|
*/ |
166
|
|
|
public function getBorderWidth() |
167
|
|
|
{ |
168
|
|
|
return $this->borderWidth; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @param int $borderWidth |
173
|
|
|
* @return Point |
174
|
|
|
*/ |
175
|
|
|
public function setBorderWidth($borderWidth) |
176
|
|
|
{ |
177
|
|
|
$this->borderWidth = intval($borderWidth); |
178
|
|
|
return $this; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* @return string |
183
|
|
|
*/ |
184
|
|
|
public function getBorderColor() |
185
|
|
|
{ |
186
|
|
|
return $this->borderColor; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* @param string $borderColor |
191
|
|
|
* @return Point |
192
|
|
|
*/ |
193
|
|
|
public function setBorderColor($borderColor) |
194
|
|
|
{ |
195
|
|
|
$this->borderColor = is_null($borderColor) ? null : strval($borderColor); |
|
|
|
|
196
|
|
|
return $this; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @return int |
201
|
|
|
*/ |
202
|
|
|
public function getHitRadius() |
203
|
|
|
{ |
204
|
|
|
return $this->hitRadius; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @param int $hitRadius |
209
|
|
|
* @return Point |
210
|
|
|
*/ |
211
|
|
|
public function setHitRadius($hitRadius) |
212
|
|
|
{ |
213
|
|
|
$this->hitRadius = intval($hitRadius); |
214
|
|
|
return $this; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @return int |
219
|
|
|
*/ |
220
|
|
|
public function getHoverRadius() |
221
|
|
|
{ |
222
|
|
|
return $this->hoverRadius; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @param int $hoverRadius |
227
|
|
|
* @return Point |
228
|
|
|
*/ |
229
|
|
|
public function setHoverRadius($hoverRadius) |
230
|
|
|
{ |
231
|
|
|
$this->hoverRadius = intval($hoverRadius); |
232
|
|
|
return $this; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @return int |
237
|
|
|
*/ |
238
|
|
|
public function getHoverBorderWidth() |
239
|
|
|
{ |
240
|
|
|
return $this->hoverBorderWidth; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @param int $hoverBorderWidth |
245
|
|
|
* @return Point |
246
|
|
|
*/ |
247
|
|
|
public function setHoverBorderWidth($hoverBorderWidth) |
248
|
|
|
{ |
249
|
|
|
$this->hoverBorderWidth = intval($hoverBorderWidth); |
250
|
|
|
return $this; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* @return string |
255
|
|
|
* @throws \ReflectionException |
256
|
|
|
* @throws \Zend_Reflection_Exception |
257
|
|
|
*/ |
258
|
|
|
public function jsonSerialize() |
259
|
|
|
{ |
260
|
|
|
return Json::encode($this->getArrayCopy()); |
261
|
|
|
} |
262
|
|
|
} |