1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Halfpastfour\PHPChartJS; |
4
|
|
|
|
5
|
|
|
use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; |
6
|
|
|
use Halfpastfour\PHPChartJS\Options\Animation; |
7
|
|
|
use Halfpastfour\PHPChartJS\Options\Elements; |
8
|
|
|
use Halfpastfour\PHPChartJS\Options\Hover; |
9
|
|
|
use Halfpastfour\PHPChartJS\Options\Layout; |
10
|
|
|
use Halfpastfour\PHPChartJS\Options\Legend; |
11
|
|
|
use Halfpastfour\PHPChartJS\Options\Scales; |
12
|
|
|
use Halfpastfour\PHPChartJS\Options\Title; |
13
|
|
|
use Halfpastfour\PHPChartJS\Options\Tooltips; |
14
|
|
|
use JsonSerializable; |
15
|
|
|
use Laminas\Json\Expr; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class Options |
19
|
|
|
* |
20
|
|
|
* @package Halfpastfour\PHPChartJS |
21
|
|
|
*/ |
22
|
|
|
class Options implements ChartOwnedInterface, ArraySerializableInterface, JsonSerializable |
23
|
|
|
{ |
24
|
|
|
use ChartOwned; |
25
|
|
|
use ArraySerializable; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var Layout |
29
|
|
|
*/ |
30
|
|
|
protected $layout; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var Title |
34
|
|
|
*/ |
35
|
|
|
protected $title; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var Elements |
39
|
|
|
*/ |
40
|
|
|
protected $elements; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var Hover |
44
|
|
|
*/ |
45
|
|
|
protected $hover; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var \Laminas\Json\Expr |
49
|
|
|
*/ |
50
|
|
|
protected $onClick; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var Scales |
54
|
|
|
*/ |
55
|
|
|
protected $scales; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var Animation |
59
|
|
|
*/ |
60
|
|
|
protected $animation; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var Legend |
64
|
|
|
*/ |
65
|
|
|
protected $legend; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var Tooltips |
69
|
|
|
*/ |
70
|
|
|
protected $tooltips; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @var bool |
74
|
|
|
*/ |
75
|
|
|
protected $maintainAspectRatio; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return Layout |
79
|
|
|
*/ |
80
|
|
|
public function getLayout() |
81
|
|
|
{ |
82
|
|
|
if (is_null($this->layout)) { |
83
|
|
|
$this->layout = new Layout(); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
return $this->layout; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return Elements |
91
|
|
|
*/ |
92
|
|
|
public function getElements() |
93
|
|
|
{ |
94
|
|
|
if (is_null($this->elements)) { |
95
|
|
|
$this->elements = new Elements(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
return $this->elements; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return Title |
103
|
|
|
*/ |
104
|
|
|
public function getTitle() |
105
|
|
|
{ |
106
|
|
|
if (is_null($this->title)) { |
107
|
|
|
$this->title = new Title(); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
return $this->title; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return Hover |
115
|
|
|
*/ |
116
|
|
|
public function getHover() |
117
|
|
|
{ |
118
|
|
|
if (is_null($this->hover)) { |
119
|
|
|
$this->hover = new Hover(); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
return $this->hover; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @return \Laminas\Json\Expr |
127
|
|
|
*/ |
128
|
|
|
public function getOnClick() |
129
|
|
|
{ |
130
|
|
|
return $this->onClick; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @param string $onClick |
135
|
|
|
* |
136
|
|
|
* @return $this |
137
|
|
|
*/ |
138
|
|
|
public function setOnClick($onClick) |
139
|
|
|
{ |
140
|
|
|
$this->onClick = new Expr(strval($onClick)); |
141
|
|
|
|
142
|
|
|
return $this; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return Scales |
147
|
|
|
*/ |
148
|
|
|
public function getScales() |
149
|
|
|
{ |
150
|
|
|
if (is_null($this->scales)) { |
151
|
|
|
$this->scales = new Scales(); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
return $this->scales; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @return Animation |
159
|
|
|
*/ |
160
|
|
|
public function getAnimation() |
161
|
|
|
{ |
162
|
|
|
if (is_null($this->animation)) { |
163
|
|
|
$this->animation = new Animation(); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
return $this->animation; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return Legend |
171
|
|
|
*/ |
172
|
|
|
public function getLegend() |
173
|
|
|
{ |
174
|
|
|
if (is_null($this->legend)) { |
175
|
|
|
$this->legend = new Legend(); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
return $this->legend; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* @return Tooltips |
183
|
|
|
*/ |
184
|
|
|
public function getTooltips() |
185
|
|
|
{ |
186
|
|
|
if (is_null($this->tooltips)) { |
187
|
|
|
$this->tooltips = new Tooltips(); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
return $this->tooltips; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @return bool |
195
|
|
|
*/ |
196
|
|
|
public function isMaintainAspectRatio() |
197
|
|
|
{ |
198
|
|
|
if (is_null($this->maintainAspectRatio)) { |
|
|
|
|
199
|
|
|
$this->maintainAspectRatio = true; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
return $this->maintainAspectRatio; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* @param bool $flag |
207
|
|
|
* |
208
|
|
|
* @return $this |
209
|
|
|
*/ |
210
|
|
|
public function setMaintainAspectRatio($flag) |
211
|
|
|
{ |
212
|
|
|
$this->maintainAspectRatio = boolval($flag); |
213
|
|
|
|
214
|
|
|
return $this; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @return array |
219
|
|
|
*/ |
220
|
|
|
public function jsonSerialize() |
221
|
|
|
{ |
222
|
|
|
return $this->getArrayCopy(); |
223
|
|
|
} |
224
|
|
|
} |
225
|
|
|
|