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