@@ -8,29 +8,29 @@ |
||
8 | 8 | */ |
9 | 9 | class JavaScript extends Renderer |
10 | 10 | { |
11 | - /** |
|
12 | - * Renders the necessary JavaScript for the chart to function in the frontend. |
|
13 | - * |
|
14 | - * @param int|null $flags |
|
15 | - * |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - public function render($flags = null) |
|
19 | - { |
|
20 | - $script = []; |
|
11 | + /** |
|
12 | + * Renders the necessary JavaScript for the chart to function in the frontend. |
|
13 | + * |
|
14 | + * @param int|null $flags |
|
15 | + * |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + public function render($flags = null) |
|
19 | + { |
|
20 | + $script = []; |
|
21 | 21 | |
22 | - // First, setup the canvas context |
|
23 | - $script[] = "var ctx = document.getElementById( \"{$this->chart->getId()}\" ).getContext( \"2d\" );"; |
|
22 | + // First, setup the canvas context |
|
23 | + $script[] = "var ctx = document.getElementById( \"{$this->chart->getId()}\" ).getContext( \"2d\" );"; |
|
24 | 24 | |
25 | - // Now, setup the chart instance |
|
26 | - $jsonRenderer = new Json($this->chart); |
|
27 | - $json = $jsonRenderer->render($flags); |
|
28 | - $script[] = "var chart = new Chart( ctx, {$json} );"; |
|
25 | + // Now, setup the chart instance |
|
26 | + $jsonRenderer = new Json($this->chart); |
|
27 | + $json = $jsonRenderer->render($flags); |
|
28 | + $script[] = "var chart = new Chart( ctx, {$json} );"; |
|
29 | 29 | |
30 | - // Return the script |
|
31 | - return "\nwindow.onload=(function(oldLoad){return function(){\n" |
|
32 | - . "if( oldLoad ) oldLoad();\n" |
|
33 | - . implode("\n", $script) . "\n" |
|
34 | - . "}})(window.onload);\n"; |
|
35 | - } |
|
30 | + // Return the script |
|
31 | + return "\nwindow.onload=(function(oldLoad){return function(){\n" |
|
32 | + . "if( oldLoad ) oldLoad();\n" |
|
33 | + . implode("\n", $script) . "\n" |
|
34 | + . "}})(window.onload);\n"; |
|
35 | + } |
|
36 | 36 | } |
@@ -17,15 +17,15 @@ |
||
17 | 17 | */ |
18 | 18 | public function render($flags = null) |
19 | 19 | { |
20 | - $script = []; |
|
20 | + $script = [ ]; |
|
21 | 21 | |
22 | 22 | // First, setup the canvas context |
23 | - $script[] = "var ctx = document.getElementById( \"{$this->chart->getId()}\" ).getContext( \"2d\" );"; |
|
23 | + $script[ ] = "var ctx = document.getElementById( \"{$this->chart->getId()}\" ).getContext( \"2d\" );"; |
|
24 | 24 | |
25 | 25 | // Now, setup the chart instance |
26 | 26 | $jsonRenderer = new Json($this->chart); |
27 | 27 | $json = $jsonRenderer->render($flags); |
28 | - $script[] = "var chart = new Chart( ctx, {$json} );"; |
|
28 | + $script[ ] = "var chart = new Chart( ctx, {$json} );"; |
|
29 | 29 | |
30 | 30 | // Return the script |
31 | 31 | return "\nwindow.onload=(function(oldLoad){return function(){\n" |
@@ -10,23 +10,23 @@ |
||
10 | 10 | */ |
11 | 11 | abstract class Renderer implements RendererInterface |
12 | 12 | { |
13 | - /** |
|
14 | - * Flag used for rendering JSON in pretty mode. |
|
15 | - */ |
|
16 | - const RENDER_PRETTY = 1; |
|
13 | + /** |
|
14 | + * Flag used for rendering JSON in pretty mode. |
|
15 | + */ |
|
16 | + const RENDER_PRETTY = 1; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @var Chart The chart that needs to be rendered. |
|
20 | - */ |
|
21 | - protected $chart; |
|
18 | + /** |
|
19 | + * @var Chart The chart that needs to be rendered. |
|
20 | + */ |
|
21 | + protected $chart; |
|
22 | 22 | |
23 | - /** |
|
24 | - * RendererInterface constructor. Expects an instance of a chart. |
|
25 | - * |
|
26 | - * @param Chart $chart The Chart that needs to be rendered. |
|
27 | - */ |
|
28 | - public function __construct(Chart $chart) |
|
29 | - { |
|
30 | - $this->chart = $chart; |
|
31 | - } |
|
23 | + /** |
|
24 | + * RendererInterface constructor. Expects an instance of a chart. |
|
25 | + * |
|
26 | + * @param Chart $chart The Chart that needs to be rendered. |
|
27 | + */ |
|
28 | + public function __construct(Chart $chart) |
|
29 | + { |
|
30 | + $this->chart = $chart; |
|
31 | + } |
|
32 | 32 | } |
@@ -9,19 +9,19 @@ |
||
9 | 9 | */ |
10 | 10 | interface RendererInterface |
11 | 11 | { |
12 | - /** |
|
13 | - * RendererInterface constructor. Expects an instance of a chart. |
|
14 | - * |
|
15 | - * @param Chart $chart |
|
16 | - */ |
|
17 | - public function __construct(Chart $chart); |
|
12 | + /** |
|
13 | + * RendererInterface constructor. Expects an instance of a chart. |
|
14 | + * |
|
15 | + * @param Chart $chart |
|
16 | + */ |
|
17 | + public function __construct(Chart $chart); |
|
18 | 18 | |
19 | - /** |
|
20 | - * Render the chart with the current strategy, returning a string. |
|
21 | - * |
|
22 | - * @param int|null $flags |
|
23 | - * |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function render($flags = null); |
|
19 | + /** |
|
20 | + * Render the chart with the current strategy, returning a string. |
|
21 | + * |
|
22 | + * @param int|null $flags |
|
23 | + * |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function render($flags = null); |
|
27 | 27 | } |
@@ -8,39 +8,39 @@ |
||
8 | 8 | */ |
9 | 9 | class Html extends Renderer |
10 | 10 | { |
11 | - /** |
|
12 | - * Renders the necessary HTML for the chart to function in the frontend. |
|
13 | - * |
|
14 | - * @param int|null $flags |
|
15 | - * |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - public function render($flags = null) |
|
19 | - { |
|
20 | - $dom = new \DOMDocument(); |
|
11 | + /** |
|
12 | + * Renders the necessary HTML for the chart to function in the frontend. |
|
13 | + * |
|
14 | + * @param int|null $flags |
|
15 | + * |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + public function render($flags = null) |
|
19 | + { |
|
20 | + $dom = new \DOMDocument(); |
|
21 | 21 | |
22 | - // Render canvas HTML element |
|
23 | - $canvas = $dom->createElement('canvas'); |
|
24 | - $canvas->setAttribute('id', $this->chart->getId()); |
|
22 | + // Render canvas HTML element |
|
23 | + $canvas = $dom->createElement('canvas'); |
|
24 | + $canvas->setAttribute('id', $this->chart->getId()); |
|
25 | 25 | |
26 | - // Add title, height and width if applicable |
|
27 | - if ($this->chart->getTitle()) { |
|
28 | - $canvas->setAttribute('title', $this->chart->getTitle()); |
|
29 | - } |
|
30 | - if ($this->chart->getHeight()) { |
|
31 | - $canvas->setAttribute('height', $this->chart->getHeight()); |
|
32 | - } |
|
33 | - if ($this->chart->getWidth()) { |
|
34 | - $canvas->setAttribute('width', $this->chart->getWidth()); |
|
35 | - } |
|
26 | + // Add title, height and width if applicable |
|
27 | + if ($this->chart->getTitle()) { |
|
28 | + $canvas->setAttribute('title', $this->chart->getTitle()); |
|
29 | + } |
|
30 | + if ($this->chart->getHeight()) { |
|
31 | + $canvas->setAttribute('height', $this->chart->getHeight()); |
|
32 | + } |
|
33 | + if ($this->chart->getWidth()) { |
|
34 | + $canvas->setAttribute('width', $this->chart->getWidth()); |
|
35 | + } |
|
36 | 36 | |
37 | - $dom->appendChild($canvas); |
|
37 | + $dom->appendChild($canvas); |
|
38 | 38 | |
39 | - // Render JavaScript |
|
40 | - $scriptRenderer = new JavaScript($this->chart); |
|
41 | - $script = $dom->createElement('script', $scriptRenderer->render($flags)); |
|
42 | - $dom->appendChild($script); |
|
39 | + // Render JavaScript |
|
40 | + $scriptRenderer = new JavaScript($this->chart); |
|
41 | + $script = $dom->createElement('script', $scriptRenderer->render($flags)); |
|
42 | + $dom->appendChild($script); |
|
43 | 43 | |
44 | - return $dom->saveHTML(); |
|
45 | - } |
|
44 | + return $dom->saveHTML(); |
|
45 | + } |
|
46 | 46 | } |
@@ -10,40 +10,40 @@ |
||
10 | 10 | */ |
11 | 11 | class Json extends Renderer |
12 | 12 | { |
13 | - /** |
|
14 | - * Render the necessary JSON for the chart to function in the frontend. |
|
15 | - * |
|
16 | - * @param int|null $flags |
|
17 | - * |
|
18 | - * @return string |
|
19 | - */ |
|
20 | - public function render($flags = null) |
|
21 | - { |
|
22 | - $config = [ |
|
23 | - 'type' => constant(get_class($this->chart) . "::TYPE"), |
|
24 | - 'data' => [], |
|
25 | - ]; |
|
26 | - |
|
27 | - $labels = $this->chart->labels()->getArrayCopy(); |
|
28 | - if ($labels) { |
|
29 | - $config['data']['labels'] = $labels; |
|
30 | - } |
|
31 | - |
|
32 | - $dataSets = $this->chart->dataSets()->getArrayCopy(); |
|
33 | - if ($dataSets) { |
|
34 | - $config['data']['datasets'] = $dataSets; |
|
35 | - } |
|
36 | - |
|
37 | - $options = $this->chart->options()->getArrayCopy(); |
|
38 | - if ($options) { |
|
39 | - $config['options'] = $options; |
|
40 | - } |
|
41 | - |
|
42 | - $output = JsonHelper::encode($config, false, [ 'enableJsonExprFinder' => true ]); |
|
43 | - if ($flags & Renderer::RENDER_PRETTY) { |
|
44 | - $output = JsonHelper::prettyPrint($output); |
|
45 | - } |
|
46 | - |
|
47 | - return $output; |
|
48 | - } |
|
13 | + /** |
|
14 | + * Render the necessary JSON for the chart to function in the frontend. |
|
15 | + * |
|
16 | + * @param int|null $flags |
|
17 | + * |
|
18 | + * @return string |
|
19 | + */ |
|
20 | + public function render($flags = null) |
|
21 | + { |
|
22 | + $config = [ |
|
23 | + 'type' => constant(get_class($this->chart) . "::TYPE"), |
|
24 | + 'data' => [], |
|
25 | + ]; |
|
26 | + |
|
27 | + $labels = $this->chart->labels()->getArrayCopy(); |
|
28 | + if ($labels) { |
|
29 | + $config['data']['labels'] = $labels; |
|
30 | + } |
|
31 | + |
|
32 | + $dataSets = $this->chart->dataSets()->getArrayCopy(); |
|
33 | + if ($dataSets) { |
|
34 | + $config['data']['datasets'] = $dataSets; |
|
35 | + } |
|
36 | + |
|
37 | + $options = $this->chart->options()->getArrayCopy(); |
|
38 | + if ($options) { |
|
39 | + $config['options'] = $options; |
|
40 | + } |
|
41 | + |
|
42 | + $output = JsonHelper::encode($config, false, [ 'enableJsonExprFinder' => true ]); |
|
43 | + if ($flags & Renderer::RENDER_PRETTY) { |
|
44 | + $output = JsonHelper::prettyPrint($output); |
|
45 | + } |
|
46 | + |
|
47 | + return $output; |
|
48 | + } |
|
49 | 49 | } |
@@ -21,22 +21,22 @@ |
||
21 | 21 | { |
22 | 22 | $config = [ |
23 | 23 | 'type' => constant(get_class($this->chart) . "::TYPE"), |
24 | - 'data' => [], |
|
24 | + 'data' => [ ], |
|
25 | 25 | ]; |
26 | 26 | |
27 | 27 | $labels = $this->chart->labels()->getArrayCopy(); |
28 | 28 | if ($labels) { |
29 | - $config['data']['labels'] = $labels; |
|
29 | + $config[ 'data' ][ 'labels' ] = $labels; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $dataSets = $this->chart->dataSets()->getArrayCopy(); |
33 | 33 | if ($dataSets) { |
34 | - $config['data']['datasets'] = $dataSets; |
|
34 | + $config[ 'data' ][ 'datasets' ] = $dataSets; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $options = $this->chart->options()->getArrayCopy(); |
38 | 38 | if ($options) { |
39 | - $config['options'] = $options; |
|
39 | + $config[ 'options' ] = $options; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $output = JsonHelper::encode($config, false, [ 'enableJsonExprFinder' => true ]); |
@@ -11,238 +11,238 @@ |
||
11 | 11 | */ |
12 | 12 | abstract class Chart implements ChartInterface |
13 | 13 | { |
14 | - /** |
|
15 | - * The internal type of chart. |
|
16 | - */ |
|
17 | - const TYPE = null; |
|
18 | - |
|
19 | - /** |
|
20 | - * The list of models that should be used for this chart type. |
|
21 | - */ |
|
22 | - const MODEL = [ |
|
23 | - 'dataset' => DataSet::class, |
|
24 | - 'options' => Options::class, |
|
25 | - ]; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - protected $id; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var int |
|
34 | - */ |
|
35 | - protected $height; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var int |
|
39 | - */ |
|
40 | - protected $width; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - protected $title; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var LabelsCollection |
|
49 | - */ |
|
50 | - protected $labels; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var Options |
|
54 | - */ |
|
55 | - protected $options; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var DataSetCollection |
|
59 | - */ |
|
60 | - protected $dataSets; |
|
61 | - |
|
62 | - /** |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - public function getId() |
|
66 | - { |
|
67 | - if (is_null($this->id)) { |
|
68 | - $this->id = uniqid('chart'); |
|
69 | - } |
|
70 | - |
|
71 | - return $this->id; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @param string $id |
|
76 | - * |
|
77 | - * @return Chart |
|
78 | - */ |
|
79 | - public function setId($id) |
|
80 | - { |
|
81 | - $this->id = strval($id); |
|
82 | - |
|
83 | - return $this; |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * @return int |
|
88 | - */ |
|
89 | - public function getHeight() |
|
90 | - { |
|
91 | - return $this->height; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * @param int $height |
|
96 | - * |
|
97 | - * @return Chart |
|
98 | - */ |
|
99 | - public function setHeight($height) |
|
100 | - { |
|
101 | - $this->height = intval($height); |
|
102 | - |
|
103 | - return $this; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * @return int |
|
108 | - */ |
|
109 | - public function getWidth() |
|
110 | - { |
|
111 | - return $this->width; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * @param int $width |
|
116 | - * |
|
117 | - * @return Chart |
|
118 | - */ |
|
119 | - public function setWidth($width) |
|
120 | - { |
|
121 | - $this->width = intval($width); |
|
122 | - |
|
123 | - return $this; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * @return string |
|
128 | - */ |
|
129 | - public function getTitle() |
|
130 | - { |
|
131 | - return $this->title; |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * @param string $title |
|
136 | - * |
|
137 | - * @return Chart |
|
138 | - */ |
|
139 | - public function setTitle($title) |
|
140 | - { |
|
141 | - $this->title = strval($title); |
|
142 | - |
|
143 | - return $this; |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @return LabelsCollection |
|
148 | - */ |
|
149 | - public function labels() |
|
150 | - { |
|
151 | - if (is_null($this->labels)) { |
|
152 | - $this->labels = new LabelsCollection(); |
|
153 | - } |
|
154 | - |
|
155 | - return $this->labels; |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * @param string $label |
|
160 | - * |
|
161 | - * @return $this |
|
162 | - */ |
|
163 | - public function addLabel($label) |
|
164 | - { |
|
165 | - $this->labels()->append($label); |
|
166 | - |
|
167 | - return $this; |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * @param $offset |
|
172 | - * |
|
173 | - * @return string|bool |
|
174 | - */ |
|
175 | - public function getLabel($offset) |
|
176 | - { |
|
177 | - return $this->labels()->offsetGet($offset); |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * @return DataSetCollection |
|
182 | - */ |
|
183 | - public function dataSets() |
|
184 | - { |
|
185 | - if (is_null($this->dataSets)) { |
|
186 | - $this->dataSets = new DataSetCollection(); |
|
187 | - } |
|
188 | - |
|
189 | - return $this->dataSets; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * @param DataSet $dataSet |
|
194 | - * |
|
195 | - * @return $this |
|
196 | - */ |
|
197 | - public function addDataSet(DataSet $dataSet) |
|
198 | - { |
|
199 | - $this->dataSets()->append($dataSet->setOwner($this)); |
|
200 | - |
|
201 | - return $this; |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * @param $offset |
|
206 | - * |
|
207 | - * @return DataSet|bool |
|
208 | - */ |
|
209 | - public function getDataSet($offset) |
|
210 | - { |
|
211 | - return $this->dataSets()->offsetGet($offset); |
|
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * @param bool $pretty |
|
216 | - * |
|
217 | - * @return string |
|
218 | - */ |
|
219 | - public function render($pretty = false) |
|
220 | - { |
|
221 | - $renderer = new Html($this); |
|
222 | - |
|
223 | - return $renderer->render(! ! $pretty ? $renderer::RENDER_PRETTY : null); |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * @return DataSet |
|
228 | - */ |
|
229 | - public function createDataSet() |
|
230 | - { |
|
231 | - $datasetClass = static::MODEL['dataset']; |
|
232 | - |
|
233 | - return new $datasetClass(); |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * @return Options |
|
238 | - */ |
|
239 | - public function options() |
|
240 | - { |
|
241 | - if (is_null($this->options)) { |
|
242 | - $optionsClass = static::MODEL['options']; |
|
243 | - $this->options = new $optionsClass($this); |
|
244 | - } |
|
245 | - |
|
246 | - return $this->options; |
|
247 | - } |
|
14 | + /** |
|
15 | + * The internal type of chart. |
|
16 | + */ |
|
17 | + const TYPE = null; |
|
18 | + |
|
19 | + /** |
|
20 | + * The list of models that should be used for this chart type. |
|
21 | + */ |
|
22 | + const MODEL = [ |
|
23 | + 'dataset' => DataSet::class, |
|
24 | + 'options' => Options::class, |
|
25 | + ]; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + protected $id; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var int |
|
34 | + */ |
|
35 | + protected $height; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var int |
|
39 | + */ |
|
40 | + protected $width; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + protected $title; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var LabelsCollection |
|
49 | + */ |
|
50 | + protected $labels; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var Options |
|
54 | + */ |
|
55 | + protected $options; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var DataSetCollection |
|
59 | + */ |
|
60 | + protected $dataSets; |
|
61 | + |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + public function getId() |
|
66 | + { |
|
67 | + if (is_null($this->id)) { |
|
68 | + $this->id = uniqid('chart'); |
|
69 | + } |
|
70 | + |
|
71 | + return $this->id; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @param string $id |
|
76 | + * |
|
77 | + * @return Chart |
|
78 | + */ |
|
79 | + public function setId($id) |
|
80 | + { |
|
81 | + $this->id = strval($id); |
|
82 | + |
|
83 | + return $this; |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * @return int |
|
88 | + */ |
|
89 | + public function getHeight() |
|
90 | + { |
|
91 | + return $this->height; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * @param int $height |
|
96 | + * |
|
97 | + * @return Chart |
|
98 | + */ |
|
99 | + public function setHeight($height) |
|
100 | + { |
|
101 | + $this->height = intval($height); |
|
102 | + |
|
103 | + return $this; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * @return int |
|
108 | + */ |
|
109 | + public function getWidth() |
|
110 | + { |
|
111 | + return $this->width; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * @param int $width |
|
116 | + * |
|
117 | + * @return Chart |
|
118 | + */ |
|
119 | + public function setWidth($width) |
|
120 | + { |
|
121 | + $this->width = intval($width); |
|
122 | + |
|
123 | + return $this; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * @return string |
|
128 | + */ |
|
129 | + public function getTitle() |
|
130 | + { |
|
131 | + return $this->title; |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * @param string $title |
|
136 | + * |
|
137 | + * @return Chart |
|
138 | + */ |
|
139 | + public function setTitle($title) |
|
140 | + { |
|
141 | + $this->title = strval($title); |
|
142 | + |
|
143 | + return $this; |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @return LabelsCollection |
|
148 | + */ |
|
149 | + public function labels() |
|
150 | + { |
|
151 | + if (is_null($this->labels)) { |
|
152 | + $this->labels = new LabelsCollection(); |
|
153 | + } |
|
154 | + |
|
155 | + return $this->labels; |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * @param string $label |
|
160 | + * |
|
161 | + * @return $this |
|
162 | + */ |
|
163 | + public function addLabel($label) |
|
164 | + { |
|
165 | + $this->labels()->append($label); |
|
166 | + |
|
167 | + return $this; |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * @param $offset |
|
172 | + * |
|
173 | + * @return string|bool |
|
174 | + */ |
|
175 | + public function getLabel($offset) |
|
176 | + { |
|
177 | + return $this->labels()->offsetGet($offset); |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * @return DataSetCollection |
|
182 | + */ |
|
183 | + public function dataSets() |
|
184 | + { |
|
185 | + if (is_null($this->dataSets)) { |
|
186 | + $this->dataSets = new DataSetCollection(); |
|
187 | + } |
|
188 | + |
|
189 | + return $this->dataSets; |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * @param DataSet $dataSet |
|
194 | + * |
|
195 | + * @return $this |
|
196 | + */ |
|
197 | + public function addDataSet(DataSet $dataSet) |
|
198 | + { |
|
199 | + $this->dataSets()->append($dataSet->setOwner($this)); |
|
200 | + |
|
201 | + return $this; |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * @param $offset |
|
206 | + * |
|
207 | + * @return DataSet|bool |
|
208 | + */ |
|
209 | + public function getDataSet($offset) |
|
210 | + { |
|
211 | + return $this->dataSets()->offsetGet($offset); |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * @param bool $pretty |
|
216 | + * |
|
217 | + * @return string |
|
218 | + */ |
|
219 | + public function render($pretty = false) |
|
220 | + { |
|
221 | + $renderer = new Html($this); |
|
222 | + |
|
223 | + return $renderer->render(! ! $pretty ? $renderer::RENDER_PRETTY : null); |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * @return DataSet |
|
228 | + */ |
|
229 | + public function createDataSet() |
|
230 | + { |
|
231 | + $datasetClass = static::MODEL['dataset']; |
|
232 | + |
|
233 | + return new $datasetClass(); |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * @return Options |
|
238 | + */ |
|
239 | + public function options() |
|
240 | + { |
|
241 | + if (is_null($this->options)) { |
|
242 | + $optionsClass = static::MODEL['options']; |
|
243 | + $this->options = new $optionsClass($this); |
|
244 | + } |
|
245 | + |
|
246 | + return $this->options; |
|
247 | + } |
|
248 | 248 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | { |
221 | 221 | $renderer = new Html($this); |
222 | 222 | |
223 | - return $renderer->render(! ! $pretty ? $renderer::RENDER_PRETTY : null); |
|
223 | + return $renderer->render(!!$pretty ? $renderer::RENDER_PRETTY : null); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function createDataSet() |
230 | 230 | { |
231 | - $datasetClass = static::MODEL['dataset']; |
|
231 | + $datasetClass = static::MODEL[ 'dataset' ]; |
|
232 | 232 | |
233 | 233 | return new $datasetClass(); |
234 | 234 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | public function options() |
240 | 240 | { |
241 | 241 | if (is_null($this->options)) { |
242 | - $optionsClass = static::MODEL['options']; |
|
242 | + $optionsClass = static::MODEL[ 'options' ]; |
|
243 | 243 | $this->options = new $optionsClass($this); |
244 | 244 | } |
245 | 245 |
@@ -8,30 +8,30 @@ |
||
8 | 8 | */ |
9 | 9 | class Factory |
10 | 10 | { |
11 | - const BAR = 'bar'; |
|
12 | - const BUBBLE = 'bubble'; |
|
13 | - const DOUGHNUT = 'doughnut'; |
|
14 | - const HORIZONTAL_BAR = 'horizontalBar'; |
|
15 | - const LINE = 'line'; |
|
16 | - const PIE = 'pie'; |
|
17 | - const POLAR_AREA = 'polarArea'; |
|
18 | - const RADAR = 'radar'; |
|
19 | - const SCATTER = 'scatter'; |
|
11 | + const BAR = 'bar'; |
|
12 | + const BUBBLE = 'bubble'; |
|
13 | + const DOUGHNUT = 'doughnut'; |
|
14 | + const HORIZONTAL_BAR = 'horizontalBar'; |
|
15 | + const LINE = 'line'; |
|
16 | + const PIE = 'pie'; |
|
17 | + const POLAR_AREA = 'polarArea'; |
|
18 | + const RADAR = 'radar'; |
|
19 | + const SCATTER = 'scatter'; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @param $type |
|
23 | - * |
|
24 | - * @return Chart |
|
25 | - */ |
|
26 | - public function create($type) |
|
27 | - { |
|
28 | - $className = ucfirst($type); |
|
29 | - $namespace = "\\Halfpastfour\\PHPChartJS\\Chart"; |
|
30 | - $path = "{$namespace}\\{$className}"; |
|
31 | - if (! class_exists($path)) { |
|
32 | - throw new \InvalidArgumentException("Invalid chart type. {$path} does not exist."); |
|
33 | - } |
|
21 | + /** |
|
22 | + * @param $type |
|
23 | + * |
|
24 | + * @return Chart |
|
25 | + */ |
|
26 | + public function create($type) |
|
27 | + { |
|
28 | + $className = ucfirst($type); |
|
29 | + $namespace = "\\Halfpastfour\\PHPChartJS\\Chart"; |
|
30 | + $path = "{$namespace}\\{$className}"; |
|
31 | + if (! class_exists($path)) { |
|
32 | + throw new \InvalidArgumentException("Invalid chart type. {$path} does not exist."); |
|
33 | + } |
|
34 | 34 | |
35 | - return new $path; |
|
36 | - } |
|
35 | + return new $path; |
|
36 | + } |
|
37 | 37 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | $className = ucfirst($type); |
29 | 29 | $namespace = "\\Halfpastfour\\PHPChartJS\\Chart"; |
30 | 30 | $path = "{$namespace}\\{$className}"; |
31 | - if (! class_exists($path)) { |
|
31 | + if (!class_exists($path)) { |
|
32 | 32 | throw new \InvalidArgumentException("Invalid chart type. {$path} does not exist."); |
33 | 33 | } |
34 | 34 |
@@ -8,212 +8,212 @@ |
||
8 | 8 | */ |
9 | 9 | class GlobalConfig |
10 | 10 | { |
11 | - /** |
|
12 | - * @var GlobalConfig |
|
13 | - */ |
|
14 | - private static $instance; |
|
15 | - |
|
16 | - /** |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - private $defaultFontColor; |
|
20 | - |
|
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - private $defaultFontFamily; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var int |
|
28 | - */ |
|
29 | - private $defaultFontSize; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - private $defaultFontStyle; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var LayoutConfig |
|
38 | - */ |
|
39 | - private $layout; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var TooltipsConfig |
|
43 | - */ |
|
44 | - private $tooltips; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var HoverConfig |
|
48 | - */ |
|
49 | - private $hover; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var AnimationConfig |
|
53 | - */ |
|
54 | - private $animation; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var ElementsConfig |
|
58 | - */ |
|
59 | - private $elements; |
|
60 | - |
|
61 | - /** |
|
62 | - * GlobalConfig constructor. |
|
63 | - */ |
|
64 | - private function __construct() |
|
65 | - { |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @return $this |
|
70 | - */ |
|
71 | - public static function getInstance() |
|
72 | - { |
|
73 | - if (is_null(self::$instance)) { |
|
74 | - self::$instance = new self; |
|
75 | - } |
|
76 | - |
|
77 | - return self::$instance; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * @return string |
|
82 | - */ |
|
83 | - public function getDefaultFontColor() |
|
84 | - { |
|
85 | - return $this->defaultFontColor; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @param string $defaultFontColor |
|
90 | - * |
|
91 | - * @return $this |
|
92 | - */ |
|
93 | - public function setDefaultFontColor($defaultFontColor) |
|
94 | - { |
|
95 | - $this->defaultFontColor = strval($defaultFontColor); |
|
96 | - |
|
97 | - return $this; |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function getDefaultFontFamily() |
|
104 | - { |
|
105 | - return $this->defaultFontFamily; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @param string $defaultFontFamily |
|
110 | - * |
|
111 | - * @return $this |
|
112 | - */ |
|
113 | - public function setDefaultFontFamily($defaultFontFamily) |
|
114 | - { |
|
115 | - $this->defaultFontFamily = strval($defaultFontFamily); |
|
116 | - |
|
117 | - return $this; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * @return int |
|
122 | - */ |
|
123 | - public function getDefaultFontSize() |
|
124 | - { |
|
125 | - return $this->defaultFontSize; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @param int $defaultFontSize |
|
130 | - * |
|
131 | - * @return $this |
|
132 | - */ |
|
133 | - public function setDefaultFontSize($defaultFontSize) |
|
134 | - { |
|
135 | - $this->defaultFontSize = intval($defaultFontSize); |
|
136 | - |
|
137 | - return $this; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * @return string |
|
142 | - */ |
|
143 | - public function getDefaultFontStyle() |
|
144 | - { |
|
145 | - return $this->defaultFontStyle; |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * @param string $defaultFontStyle |
|
150 | - * |
|
151 | - * @return $this |
|
152 | - */ |
|
153 | - public function setDefaultFontStyle($defaultFontStyle) |
|
154 | - { |
|
155 | - $this->defaultFontStyle = $defaultFontStyle; |
|
156 | - |
|
157 | - return $this; |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * @return LayoutConfig |
|
162 | - */ |
|
163 | - public function layout() |
|
164 | - { |
|
165 | - if (is_null($this->layout)) { |
|
166 | - $this->layout = new LayoutConfig(); |
|
167 | - } |
|
168 | - |
|
169 | - return $this->layout; |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * @return TooltipsConfig |
|
174 | - */ |
|
175 | - public function tooltips() |
|
176 | - { |
|
177 | - if (is_null($this->tooltips)) { |
|
178 | - $this->tooltips = new TooltipsConfig(); |
|
179 | - } |
|
180 | - |
|
181 | - return $this->tooltips; |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * @return HoverConfig |
|
186 | - */ |
|
187 | - public function hover() |
|
188 | - { |
|
189 | - if (is_null($this->hover)) { |
|
190 | - $this->hover = new HoverConfig(); |
|
191 | - } |
|
192 | - |
|
193 | - return $this->hover; |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * @return AnimationConfig |
|
198 | - */ |
|
199 | - public function animation() |
|
200 | - { |
|
201 | - if (is_null($this->animation)) { |
|
202 | - $this->animation = new AnimationConfig(); |
|
203 | - } |
|
204 | - |
|
205 | - return $this->animation; |
|
206 | - } |
|
207 | - |
|
208 | - /** |
|
209 | - * @return ElementsConfig |
|
210 | - */ |
|
211 | - public function elements() |
|
212 | - { |
|
213 | - if (is_null($this->elements)) { |
|
214 | - $this->elements = new ElementsConfig(); |
|
215 | - } |
|
216 | - |
|
217 | - return $this->elements; |
|
218 | - } |
|
11 | + /** |
|
12 | + * @var GlobalConfig |
|
13 | + */ |
|
14 | + private static $instance; |
|
15 | + |
|
16 | + /** |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + private $defaultFontColor; |
|
20 | + |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + private $defaultFontFamily; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var int |
|
28 | + */ |
|
29 | + private $defaultFontSize; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + private $defaultFontStyle; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var LayoutConfig |
|
38 | + */ |
|
39 | + private $layout; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var TooltipsConfig |
|
43 | + */ |
|
44 | + private $tooltips; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var HoverConfig |
|
48 | + */ |
|
49 | + private $hover; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var AnimationConfig |
|
53 | + */ |
|
54 | + private $animation; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var ElementsConfig |
|
58 | + */ |
|
59 | + private $elements; |
|
60 | + |
|
61 | + /** |
|
62 | + * GlobalConfig constructor. |
|
63 | + */ |
|
64 | + private function __construct() |
|
65 | + { |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @return $this |
|
70 | + */ |
|
71 | + public static function getInstance() |
|
72 | + { |
|
73 | + if (is_null(self::$instance)) { |
|
74 | + self::$instance = new self; |
|
75 | + } |
|
76 | + |
|
77 | + return self::$instance; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * @return string |
|
82 | + */ |
|
83 | + public function getDefaultFontColor() |
|
84 | + { |
|
85 | + return $this->defaultFontColor; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @param string $defaultFontColor |
|
90 | + * |
|
91 | + * @return $this |
|
92 | + */ |
|
93 | + public function setDefaultFontColor($defaultFontColor) |
|
94 | + { |
|
95 | + $this->defaultFontColor = strval($defaultFontColor); |
|
96 | + |
|
97 | + return $this; |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + public function getDefaultFontFamily() |
|
104 | + { |
|
105 | + return $this->defaultFontFamily; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @param string $defaultFontFamily |
|
110 | + * |
|
111 | + * @return $this |
|
112 | + */ |
|
113 | + public function setDefaultFontFamily($defaultFontFamily) |
|
114 | + { |
|
115 | + $this->defaultFontFamily = strval($defaultFontFamily); |
|
116 | + |
|
117 | + return $this; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * @return int |
|
122 | + */ |
|
123 | + public function getDefaultFontSize() |
|
124 | + { |
|
125 | + return $this->defaultFontSize; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * @param int $defaultFontSize |
|
130 | + * |
|
131 | + * @return $this |
|
132 | + */ |
|
133 | + public function setDefaultFontSize($defaultFontSize) |
|
134 | + { |
|
135 | + $this->defaultFontSize = intval($defaultFontSize); |
|
136 | + |
|
137 | + return $this; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * @return string |
|
142 | + */ |
|
143 | + public function getDefaultFontStyle() |
|
144 | + { |
|
145 | + return $this->defaultFontStyle; |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * @param string $defaultFontStyle |
|
150 | + * |
|
151 | + * @return $this |
|
152 | + */ |
|
153 | + public function setDefaultFontStyle($defaultFontStyle) |
|
154 | + { |
|
155 | + $this->defaultFontStyle = $defaultFontStyle; |
|
156 | + |
|
157 | + return $this; |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * @return LayoutConfig |
|
162 | + */ |
|
163 | + public function layout() |
|
164 | + { |
|
165 | + if (is_null($this->layout)) { |
|
166 | + $this->layout = new LayoutConfig(); |
|
167 | + } |
|
168 | + |
|
169 | + return $this->layout; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * @return TooltipsConfig |
|
174 | + */ |
|
175 | + public function tooltips() |
|
176 | + { |
|
177 | + if (is_null($this->tooltips)) { |
|
178 | + $this->tooltips = new TooltipsConfig(); |
|
179 | + } |
|
180 | + |
|
181 | + return $this->tooltips; |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * @return HoverConfig |
|
186 | + */ |
|
187 | + public function hover() |
|
188 | + { |
|
189 | + if (is_null($this->hover)) { |
|
190 | + $this->hover = new HoverConfig(); |
|
191 | + } |
|
192 | + |
|
193 | + return $this->hover; |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * @return AnimationConfig |
|
198 | + */ |
|
199 | + public function animation() |
|
200 | + { |
|
201 | + if (is_null($this->animation)) { |
|
202 | + $this->animation = new AnimationConfig(); |
|
203 | + } |
|
204 | + |
|
205 | + return $this->animation; |
|
206 | + } |
|
207 | + |
|
208 | + /** |
|
209 | + * @return ElementsConfig |
|
210 | + */ |
|
211 | + public function elements() |
|
212 | + { |
|
213 | + if (is_null($this->elements)) { |
|
214 | + $this->elements = new ElementsConfig(); |
|
215 | + } |
|
216 | + |
|
217 | + return $this->elements; |
|
218 | + } |
|
219 | 219 | } |
@@ -18,133 +18,133 @@ |
||
18 | 18 | */ |
19 | 19 | class Options implements ChartOwnedInterface, ArraySerializableInterface, \JsonSerializable |
20 | 20 | { |
21 | - use ChartOwned; |
|
22 | - use ArraySerializable; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var Layout |
|
26 | - */ |
|
27 | - protected $layout; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var Title |
|
31 | - */ |
|
32 | - protected $title; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var Hover |
|
36 | - */ |
|
37 | - protected $hover; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var Scales |
|
41 | - */ |
|
42 | - protected $scales; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var Animation |
|
46 | - */ |
|
47 | - protected $animation; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var Legend |
|
51 | - */ |
|
52 | - protected $legend; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var Tooltips |
|
56 | - */ |
|
57 | - protected $tooltips; |
|
58 | - |
|
59 | - /** |
|
60 | - * @return Layout |
|
61 | - */ |
|
62 | - public function getLayout() |
|
63 | - { |
|
64 | - if (is_null($this->layout)) { |
|
65 | - $this->layout = new Layout(); |
|
66 | - } |
|
67 | - |
|
68 | - return $this->layout; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @return Title |
|
73 | - */ |
|
74 | - public function getTitle() |
|
75 | - { |
|
76 | - if (is_null($this->title)) { |
|
77 | - $this->title = new Title(); |
|
78 | - } |
|
79 | - |
|
80 | - return $this->title; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * @return Hover |
|
85 | - */ |
|
86 | - public function getHover() |
|
87 | - { |
|
88 | - if (is_null($this->hover)) { |
|
89 | - $this->hover = new Hover(); |
|
90 | - } |
|
91 | - |
|
92 | - return $this->hover; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * @return Scales |
|
97 | - */ |
|
98 | - public function getScales() |
|
99 | - { |
|
100 | - if (is_null($this->scales)) { |
|
101 | - $this->scales = new Scales(); |
|
102 | - } |
|
103 | - |
|
104 | - return $this->scales; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @return Animation |
|
109 | - */ |
|
110 | - public function getAnimation() |
|
111 | - { |
|
112 | - if (is_null($this->animation)) { |
|
113 | - $this->animation = new Animation(); |
|
114 | - } |
|
115 | - |
|
116 | - return $this->animation; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * @return Legend |
|
121 | - */ |
|
122 | - public function getLegend() |
|
123 | - { |
|
124 | - if (is_null($this->legend)) { |
|
125 | - $this->legend = new Legend(); |
|
126 | - } |
|
127 | - |
|
128 | - return $this->legend; |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * @return Tooltips |
|
133 | - */ |
|
134 | - public function getTooltips() |
|
135 | - { |
|
136 | - if (is_null($this->tooltips)) { |
|
137 | - $this->tooltips = new Tooltips(); |
|
138 | - } |
|
139 | - |
|
140 | - return $this->tooltips; |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * @return string |
|
145 | - */ |
|
146 | - public function jsonSerialize() |
|
147 | - { |
|
148 | - return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); |
|
149 | - } |
|
21 | + use ChartOwned; |
|
22 | + use ArraySerializable; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var Layout |
|
26 | + */ |
|
27 | + protected $layout; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var Title |
|
31 | + */ |
|
32 | + protected $title; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var Hover |
|
36 | + */ |
|
37 | + protected $hover; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var Scales |
|
41 | + */ |
|
42 | + protected $scales; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var Animation |
|
46 | + */ |
|
47 | + protected $animation; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var Legend |
|
51 | + */ |
|
52 | + protected $legend; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var Tooltips |
|
56 | + */ |
|
57 | + protected $tooltips; |
|
58 | + |
|
59 | + /** |
|
60 | + * @return Layout |
|
61 | + */ |
|
62 | + public function getLayout() |
|
63 | + { |
|
64 | + if (is_null($this->layout)) { |
|
65 | + $this->layout = new Layout(); |
|
66 | + } |
|
67 | + |
|
68 | + return $this->layout; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @return Title |
|
73 | + */ |
|
74 | + public function getTitle() |
|
75 | + { |
|
76 | + if (is_null($this->title)) { |
|
77 | + $this->title = new Title(); |
|
78 | + } |
|
79 | + |
|
80 | + return $this->title; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * @return Hover |
|
85 | + */ |
|
86 | + public function getHover() |
|
87 | + { |
|
88 | + if (is_null($this->hover)) { |
|
89 | + $this->hover = new Hover(); |
|
90 | + } |
|
91 | + |
|
92 | + return $this->hover; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * @return Scales |
|
97 | + */ |
|
98 | + public function getScales() |
|
99 | + { |
|
100 | + if (is_null($this->scales)) { |
|
101 | + $this->scales = new Scales(); |
|
102 | + } |
|
103 | + |
|
104 | + return $this->scales; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @return Animation |
|
109 | + */ |
|
110 | + public function getAnimation() |
|
111 | + { |
|
112 | + if (is_null($this->animation)) { |
|
113 | + $this->animation = new Animation(); |
|
114 | + } |
|
115 | + |
|
116 | + return $this->animation; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * @return Legend |
|
121 | + */ |
|
122 | + public function getLegend() |
|
123 | + { |
|
124 | + if (is_null($this->legend)) { |
|
125 | + $this->legend = new Legend(); |
|
126 | + } |
|
127 | + |
|
128 | + return $this->legend; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * @return Tooltips |
|
133 | + */ |
|
134 | + public function getTooltips() |
|
135 | + { |
|
136 | + if (is_null($this->tooltips)) { |
|
137 | + $this->tooltips = new Tooltips(); |
|
138 | + } |
|
139 | + |
|
140 | + return $this->tooltips; |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * @return string |
|
145 | + */ |
|
146 | + public function jsonSerialize() |
|
147 | + { |
|
148 | + return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); |
|
149 | + } |
|
150 | 150 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | public function getLayout() |
63 | 63 | { |
64 | 64 | if (is_null($this->layout)) { |
65 | - $this->layout = new Layout(); |
|
65 | + $this->layout = new Layout(); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | return $this->layout; |