1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Halfpastfour\PHPChartJS\Options; |
4
|
|
|
|
5
|
|
|
use Halfpastfour\PHPChartJS\ArraySerializableInterface; |
6
|
|
|
use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; |
7
|
|
|
use Halfpastfour\PHPChartJS\LabelsCollection; |
8
|
|
|
use JsonSerializable; |
9
|
|
|
use Laminas\Json\Expr; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class Legend |
13
|
|
|
* |
14
|
|
|
* @package Halfpastfour\PHPChartJS\Options |
15
|
|
|
*/ |
16
|
|
|
class Legend implements ArraySerializableInterface, JsonSerializable |
17
|
|
|
{ |
18
|
|
|
use ArraySerializable; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var bool |
22
|
|
|
*/ |
23
|
|
|
private $display; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
private $position; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var bool |
32
|
|
|
*/ |
33
|
|
|
private $fullWidth; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var Expr |
37
|
|
|
*/ |
38
|
|
|
private $onClick; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var Expr |
42
|
|
|
*/ |
43
|
|
|
private $onHover; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var LabelsCollection |
47
|
|
|
*/ |
48
|
|
|
private $labels; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var bool |
52
|
|
|
*/ |
53
|
|
|
private $reverse; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return bool |
57
|
|
|
*/ |
58
|
|
|
public function isDisplay() |
59
|
|
|
{ |
60
|
|
|
return $this->display; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param bool $display |
65
|
|
|
* |
66
|
|
|
* @return $this |
67
|
|
|
*/ |
68
|
|
|
public function setDisplay($display) |
69
|
|
|
{ |
70
|
|
|
$this->display = boolval($display); |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return string |
77
|
|
|
*/ |
78
|
|
|
public function getPosition() |
79
|
|
|
{ |
80
|
|
|
return $this->position; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param string $position |
85
|
|
|
* |
86
|
|
|
* @return $this |
87
|
|
|
*/ |
88
|
|
|
public function setPosition($position) |
89
|
|
|
{ |
90
|
|
|
$this->position = strval($position); |
91
|
|
|
|
92
|
|
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return bool |
97
|
|
|
*/ |
98
|
|
|
public function isFullWidth() |
99
|
|
|
{ |
100
|
|
|
return $this->fullWidth; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param bool $fullWidth |
105
|
|
|
* |
106
|
|
|
* @return $this |
107
|
|
|
*/ |
108
|
|
|
public function setFullWidth($fullWidth) |
109
|
|
|
{ |
110
|
|
|
$this->fullWidth = boolval($fullWidth); |
111
|
|
|
|
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return Expr |
117
|
|
|
*/ |
118
|
|
|
public function getOnClick() |
119
|
|
|
{ |
120
|
|
|
return $this->onClick; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @param string $onClick |
125
|
|
|
* |
126
|
|
|
* @return $this |
127
|
|
|
*/ |
128
|
|
|
public function setOnClick($onClick) |
129
|
|
|
{ |
130
|
|
|
$this->onClick = new Expr(strval($onClick)); |
131
|
|
|
|
132
|
|
|
return $this; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @return Expr |
137
|
|
|
*/ |
138
|
|
|
public function getOnHover() |
139
|
|
|
{ |
140
|
|
|
return $this->onHover; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @param string $onHover |
145
|
|
|
* |
146
|
|
|
* @return $this |
147
|
|
|
*/ |
148
|
|
|
public function setOnHover($onHover) |
149
|
|
|
{ |
150
|
|
|
$this->onHover = new Expr(strval($onHover)); |
151
|
|
|
|
152
|
|
|
return $this; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return LabelsCollection |
157
|
|
|
*/ |
158
|
|
|
public function labels() |
159
|
|
|
{ |
160
|
|
|
if (is_null($this->labels)) { |
161
|
|
|
$this->labels = new LabelsCollection(); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
return $this->labels; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @return bool |
169
|
|
|
*/ |
170
|
|
|
public function isReverse() |
171
|
|
|
{ |
172
|
|
|
return $this->reverse; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @param bool $reverse |
177
|
|
|
* |
178
|
|
|
* @return $this |
179
|
|
|
*/ |
180
|
|
|
public function setReverse($reverse) |
181
|
|
|
{ |
182
|
|
|
$this->reverse = boolval($reverse); |
183
|
|
|
|
184
|
|
|
return $this; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @return array |
189
|
|
|
*/ |
190
|
|
|
public function jsonSerialize() |
191
|
|
|
{ |
192
|
|
|
return $this->getArrayCopy(); |
193
|
|
|
} |
194
|
|
|
} |
195
|
|
|
|