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 Zend\Json\Json; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class Options |
18
|
|
|
* @package Halfpastfour\PHPChartJS |
19
|
|
|
*/ |
20
|
|
|
class Options implements ChartOwnedInterface, ArraySerializableInterface, \JsonSerializable |
21
|
|
|
{ |
22
|
|
|
use ChartOwned; |
23
|
|
|
use ArraySerializable; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var Layout |
27
|
|
|
*/ |
28
|
|
|
protected $layout; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var Title |
32
|
|
|
*/ |
33
|
|
|
protected $title; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var Elements |
37
|
|
|
*/ |
38
|
|
|
protected $elements; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var Hover |
42
|
|
|
*/ |
43
|
|
|
protected $hover; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var Scales |
47
|
|
|
*/ |
48
|
|
|
protected $scales; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var Animation |
52
|
|
|
*/ |
53
|
|
|
protected $animation; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var Legend |
57
|
|
|
*/ |
58
|
|
|
protected $legend; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var Tooltips |
62
|
|
|
*/ |
63
|
|
|
protected $tooltips; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return Layout |
67
|
|
|
*/ |
68
|
|
|
public function getLayout() |
69
|
|
|
{ |
70
|
|
|
if (is_null($this->layout)) { |
71
|
|
|
$this->layout = new Layout(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return $this->layout; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return Elements |
79
|
|
|
*/ |
80
|
|
|
public function getElements() |
81
|
|
|
{ |
82
|
|
|
if (is_null($this->elements)) { |
83
|
|
|
$this->elements = new Elements(); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
return $this->elements; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return Title |
91
|
|
|
*/ |
92
|
|
|
public function getTitle() |
93
|
|
|
{ |
94
|
|
|
if (is_null($this->title)) { |
95
|
|
|
$this->title = new Title(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
return $this->title; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return Hover |
103
|
|
|
*/ |
104
|
|
|
public function getHover() |
105
|
|
|
{ |
106
|
|
|
if (is_null($this->hover)) { |
107
|
|
|
$this->hover = new Hover(); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
return $this->hover; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return Scales |
115
|
|
|
*/ |
116
|
|
|
public function getScales() |
117
|
|
|
{ |
118
|
|
|
if (is_null($this->scales)) { |
119
|
|
|
$this->scales = new Scales(); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
return $this->scales; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @return Animation |
127
|
|
|
*/ |
128
|
|
|
public function getAnimation() |
129
|
|
|
{ |
130
|
|
|
if (is_null($this->animation)) { |
131
|
|
|
$this->animation = new Animation(); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
return $this->animation; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return Legend |
139
|
|
|
*/ |
140
|
|
|
public function getLegend() |
141
|
|
|
{ |
142
|
|
|
if (is_null($this->legend)) { |
143
|
|
|
$this->legend = new Legend(); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
return $this->legend; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @return Tooltips |
151
|
|
|
*/ |
152
|
|
|
public function getTooltips() |
153
|
|
|
{ |
154
|
|
|
if (is_null($this->tooltips)) { |
155
|
|
|
$this->tooltips = new Tooltips(); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
return $this->tooltips; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @return string |
163
|
|
|
*/ |
164
|
|
|
public function jsonSerialize() |
165
|
|
|
{ |
166
|
|
|
return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
|