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