@@ -46,8 +46,8 @@ |
||
46 | 46 | $js = ''; |
47 | 47 | |
48 | 48 | foreach ($this->listeners as $listener) { |
49 | - $js .= "google.visualization.events.addListener(" . $this->chart->getName() . ", '" . $listener->getType() . |
|
50 | - "', " . $listener->getFunction() . ");"; |
|
49 | + $js .= "google.visualization.events.addListener(".$this->chart->getName().", '".$listener->getType(). |
|
50 | + "', ".$listener->getFunction().");"; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | return $js; |
@@ -40,6 +40,6 @@ |
||
40 | 40 | |
41 | 41 | $options = $this->optionsFormat->renameRecursivelyKeys($options); |
42 | 42 | |
43 | - return "var $optionsName = " . json_encode($options) . ";\n"; |
|
43 | + return "var $optionsName = ".json_encode($options).";\n"; |
|
44 | 44 | } |
45 | 45 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | parent::__construct(); |
51 | 51 | |
52 | 52 | $this->timeline = new Timeline(); |
53 | - $this->tooltip = new BasicTooltip(); |
|
53 | + $this->tooltip = new BasicTooltip(); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 |
@@ -16,7 +16,7 @@ |
||
16 | 16 | */ |
17 | 17 | public function removeRecursivelyNullValue(&$options) |
18 | 18 | { |
19 | - $options = array_filter((array)$options, function ($val) { |
|
19 | + $options = array_filter((array)$options, function($val) { |
|
20 | 20 | return !is_null($val); |
21 | 21 | }); |
22 | 22 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function getName() |
48 | 48 | { |
49 | - return 'chart' . ucfirst($this->elementID); |
|
49 | + return 'chart'.ucfirst($this->elementID); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function getDataName() |
58 | 58 | { |
59 | - return 'data'. ucfirst($this->getName()); |
|
59 | + return 'data'.ucfirst($this->getName()); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getOptionsName() |
68 | 68 | { |
69 | - return 'options'. ucfirst($this->getName()); |
|
69 | + return 'options'.ucfirst($this->getName()); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -110,18 +110,18 @@ discard block |
||
110 | 110 | throw new GoogleChartsException('Container is not defined.'); |
111 | 111 | } |
112 | 112 | |
113 | - $js = 'var ' . $this->getName() . ' = new google.visualization.' . $this->getType() . |
|
114 | - '(document.getElementById("' . $this->elementID . '"));'; |
|
113 | + $js = 'var '.$this->getName().' = new google.visualization.'.$this->getType(). |
|
114 | + '(document.getElementById("'.$this->elementID.'"));'; |
|
115 | 115 | |
116 | 116 | if (!$this instanceof DiffChart) { |
117 | 117 | $js .= $this->data->draw($this->getDataName()); |
118 | 118 | |
119 | 119 | } else { |
120 | - $js .= $this->getOldChart()->getData()->draw('old_' . $this->getDataName()) . |
|
121 | - $this->getNewChart()->getData()->draw('new_' . $this->getDataName()) . |
|
122 | - 'var ' . $this->getDataName() . ' = ' . $this->getName() . |
|
123 | - '.computeDiff(old_' . $this->getDataName() . ', |
|
124 | - new_' . $this->getDataName() . ');'; |
|
120 | + $js .= $this->getOldChart()->getData()->draw('old_'.$this->getDataName()). |
|
121 | + $this->getNewChart()->getData()->draw('new_'.$this->getDataName()). |
|
122 | + 'var '.$this->getDataName().' = '.$this->getName(). |
|
123 | + '.computeDiff(old_'.$this->getDataName().', |
|
124 | + new_' . $this->getDataName().');'; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | $js .= $this->options->draw($this->getOptionsName()); |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function endDraw() |
138 | 138 | { |
139 | - return $this->events->draw(). $this->getName() . |
|
140 | - '.draw('. $this->getDataName() . ', '. $this->getOptionsName() .');'; |
|
139 | + return $this->events->draw().$this->getName(). |
|
140 | + '.draw('.$this->getDataName().', '.$this->getOptionsName().');'; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | ); |
160 | 160 | } |
161 | 161 | |
162 | - $callback = function ($item) { |
|
162 | + $callback = function($item) { |
|
163 | 163 | if (!is_string($item)) { |
164 | 164 | throw new GoogleChartsException('A string is expected for HTML element ID.'); |
165 | 165 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | private function checkChartType($charts) |
187 | 187 | { |
188 | - $callback = function ($item) { |
|
188 | + $callback = function($item) { |
|
189 | 189 | if (!$item instanceof Chart) { |
190 | 190 | throw new GoogleChartsException('An instance of Chart or an array of Chart is expected.'); |
191 | 191 | } |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | */ |
203 | 203 | private function loadLibraries($packages) |
204 | 204 | { |
205 | - array_walk($packages, function (&$item) { |
|
206 | - $item = "'" . $item . "'"; |
|
205 | + array_walk($packages, function(&$item) { |
|
206 | + $item = "'".$item."'"; |
|
207 | 207 | }); |
208 | 208 | |
209 | - ($this->language) ? $language = ", language: '" . $this->language . "'" : $language = ''; |
|
209 | + ($this->language) ? $language = ", language: '".$this->language."'" : $language = ''; |
|
210 | 210 | |
211 | - $load = "'" . $this->version . "', {packages:[" . implode(',', $packages) . ']' . $language . '}'; |
|
211 | + $load = "'".$this->version."', {packages:[".implode(',', $packages).']'.$language.'}'; |
|
212 | 212 | |
213 | 213 | return "google.charts.load($load);"; |
214 | 214 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | $js = $this->loadLibraries($packages); |
263 | 263 | |
264 | - $js .= $this->startCallback('drawChart' . ucfirst(md5($drawChartName))); |
|
264 | + $js .= $this->startCallback('drawChart'.ucfirst(md5($drawChartName))); |
|
265 | 265 | |
266 | 266 | foreach ($charts as $chart) { |
267 | 267 | $js .= $chart->startDraw(); |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public function drawCharts($charts, $elementsID = null) |
302 | 302 | { |
303 | - return $this->startCharts($charts, $elementsID) . $this->endCharts($charts); |
|
303 | + return $this->startCharts($charts, $elementsID).$this->endCharts($charts); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -65,9 +65,9 @@ |
||
65 | 65 | $lastKeyValue = key($row); |
66 | 66 | foreach ($row as $key => $value) { |
67 | 67 | if ($value instanceof \DateTime) { |
68 | - $js .= 'new Date(' . $value->format('Y') . ', ' . ($value->format('n') - 1) . ', ' . |
|
69 | - $value->format('d') . ', ' . $value->format('H') . ', ' . $value->format('i') . ', ' . |
|
70 | - $value->format('s') . ')'; |
|
68 | + $js .= 'new Date('.$value->format('Y').', '.($value->format('n')-1).', '. |
|
69 | + $value->format('d').', '.$value->format('H').', '.$value->format('i').', '. |
|
70 | + $value->format('s').')'; |
|
71 | 71 | } else { |
72 | 72 | $js .= json_encode($value); |
73 | 73 | } |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | $this->chart->setElementID('div-chart') |
28 | 28 | ->getData()->setArrayToDataTable([ |
29 | 29 | ['Time of Day', 'Motivation Level', ['role' => 'annotation'], 'Energy Level', ['role' => 'annotation']], |
30 | - [['v' => [8, 0, 0], 'f' => '8 am'], 1, '1', 0.25, '0.2'], |
|
31 | - [['v' => [9, 0, 0], 'f' => '9 am'], 2, '2', 0.5, '0.5'], |
|
32 | - [['v' => [10, 0, 0], 'f' => '10 am'], 3, '3', 1, '1'], |
|
33 | - [['v' => [11, 0, 0], 'f' => '11 am'], 4, '4', 2.25, '2'], |
|
34 | - [['v' => [12, 0, 0], 'f' => '12 am'], 5, '5', 2.25, '2'], |
|
35 | - [['v' => [13, 0, 0], 'f' => '1 pm'], 6, '6', 3, '3'], |
|
36 | - [['v' => [14, 0, 0], 'f' => '2 pm'], 7, '7', 3.25, '3'], |
|
37 | - [['v' => [15, 0, 0], 'f' => '3 pm'], 8, '8', 5, '5'], |
|
38 | - [['v' => [16, 0, 0], 'f' => '4 pm'], 9, '9', 6.5, '6'], |
|
39 | - [['v' => [17, 0, 0], 'f' => '5 pm'], 10, '10', 10, '10'] |
|
30 | + [['v' => [8, 0, 0], 'f' => '8 am'], 1, '1', 0.25, '0.2'], |
|
31 | + [['v' => [9, 0, 0], 'f' => '9 am'], 2, '2', 0.5, '0.5'], |
|
32 | + [['v' => [10, 0, 0], 'f' => '10 am'], 3, '3', 1, '1'], |
|
33 | + [['v' => [11, 0, 0], 'f' => '11 am'], 4, '4', 2.25, '2'], |
|
34 | + [['v' => [12, 0, 0], 'f' => '12 am'], 5, '5', 2.25, '2'], |
|
35 | + [['v' => [13, 0, 0], 'f' => '1 pm'], 6, '6', 3, '3'], |
|
36 | + [['v' => [14, 0, 0], 'f' => '2 pm'], 7, '7', 3.25, '3'], |
|
37 | + [['v' => [15, 0, 0], 'f' => '3 pm'], 8, '8', 5, '5'], |
|
38 | + [['v' => [16, 0, 0], 'f' => '4 pm'], 9, '9', 6.5, '6'], |
|
39 | + [['v' => [17, 0, 0], 'f' => '5 pm'], 10, '10', 10, '10'] |
|
40 | 40 | ]); |
41 | 41 | |
42 | 42 | $this->chart->getOptions()->getAnimation() |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | ->setWidth('auto') |
103 | 103 | ->setHeight('auto'); |
104 | 104 | |
105 | - $this->chart->getOptions()->setColors(['red','#004411']); |
|
105 | + $this->chart->getOptions()->setColors(['red', '#004411']); |
|
106 | 106 | |
107 | 107 | $this->chart->getOptions()->setDataOpacity(1.0); |
108 | 108 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | ->setItalic(true) |
175 | 175 | ->setColor('black'); |
176 | 176 | $this->chart->getOptions()->getHAxis() |
177 | - ->setTicks([5,10,15,20]) |
|
177 | + ->setTicks([5, 10, 15, 20]) |
|
178 | 178 | ->setTitle('title') |
179 | 179 | ->getTitleTextStyle() |
180 | 180 | ->setColor('black') |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | ->setItalic(true) |
305 | 305 | ->setColor('black'); |
306 | 306 | $this->chart->getOptions()->getVAxis() |
307 | - ->setTicks([5,10,15,20]) |
|
307 | + ->setTicks([5, 10, 15, 20]) |
|
308 | 308 | ->setTitle('title') |
309 | 309 | ->getTitleTextStyle() |
310 | 310 | ->setColor('black') |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | public function testJsColumnChart() |
328 | 328 | { |
329 | - $js = $this->chart->startDraw() . $this->chart->endDraw(); |
|
329 | + $js = $this->chart->startDraw().$this->chart->endDraw(); |
|
330 | 330 | |
331 | 331 | $this->assertContains('{"animation":{"startup":true,"duration":1000,"easing":"in"},"annotations":{"alwaysOutside":true,"boxStyle":{"stroke":"#888","strokeWidth":1,"rx":10,"ry":10},"datum":{"stem":{"color":"black","length":12},"style":"point"},"domain":{"stem":{"color":"black","length":5},"style":"point"},"highContrast":true,"stem":{"color":"black","length":5},"style":"point","textStyle":{"auraColor":"#d799ae","opacity":0.8,"bold":true,"italic":true,"color":"#871b47","fontName":"Times-Roman","fontSize":18}},"bar":{"groupWidth":"61.8%"},"dataOpacity":1,"explorer":{"actions":["dragToPan","rightClickToReset"],"axis":"vertical","keepInBounds":false,"maxZoomIn":0.25,"maxZoomOut":4,"zoomDelta":1.5},"focusTarget":"datum","hAxis":{"allowContainerBoundaryTextCufoff":false,"slantedText":false,"slantedTextAngle":30,"maxAlternation":2,"maxTextLines":5,"minTextSpacing":5,"showTextEvery":1,"baseline":5,"baselineColor":"black","direction":1,"format":"decimal","logScale":false,"scaleType":"log","maxValue":100,"minValue":1,"ticks":[5,10,15,20],"gridlines":{"color":"#CCC","count":5,"units":{"years":{"format":"yyyy"},"months":{"format":"M"},"days":{"format":"d"},"hours":{"format":"H"},"minutes":{"format":"i"},"seconds":{"format":"s"},"milliseconds":{"format":"u"}}},"minorGridlines":{"color":"black","count":0,"units":{"years":{"format":"yyyy"},"months":{"format":"M"},"days":{"format":"d"},"hours":{"format":"H"},"minutes":{"format":"i"},"seconds":{"format":"s"},"milliseconds":{"format":"u"}}},"textPosition":"out","textStyle":{"bold":true,"italic":true,"color":"black","fontName":"Times-Roman","fontSize":12},"title":"title","titleTextStyle":{"color":"black","fontName":"Arial","fontSize":18,"bold":true,"italic":true},"viewWindow":{"max":100,"min":1},"viewWindowMode":"pretty"},"isStacked":false,"legend":{"alignment":"start","position":"right","textStyle":{"bold":false,"italic":false,"color":"black","fontName":"Arial","fontSize":10}},"orientation":"horizontal","reverseCategories":false,"tooltip":{"ignoreBounds":false,"showColorCode":false,"textStyle":{"bold":false,"italic":false,"color":"black","fontName":"Arial","fontSize":10},"trigger":"focus","isHtml":false},"vAxes":[{"title":"v1"},{"title":"v2"}],"axisTitlesPosition":"out","series":{"0":{"color":"black","visibleInLegend":false},"3":{"color":"red","visibleInLegend":false}},"theme":"maximized","titlePosition":"out","vAxis":{"baseline":5,"baselineColor":"black","direction":1,"format":"decimal","gridlines":{"color":"#CCC","count":5,"units":{"years":{"format":"yyyy"},"months":{"format":"M"},"days":{"format":"d"},"hours":{"format":"H"},"minutes":{"format":"i"},"seconds":{"format":"s"},"milliseconds":{"format":"u"}}},"minorGridlines":{"color":"black","count":0,"units":{"years":{"format":"yyyy"},"months":{"format":"M"},"days":{"format":"d"},"hours":{"format":"H"},"minutes":{"format":"i"},"seconds":{"format":"s"},"milliseconds":{"format":"u"}}},"logScale":false,"scaleType":"log","textPosition":"out","textStyle":{"bold":true,"italic":true,"color":"black","fontName":"Times-Roman","fontSize":12},"ticks":[5,10,15,20],"title":"title","titleTextStyle":{"color":"black","fontName":"Arial","fontSize":18,"bold":true,"italic":true},"maxValue":100,"minValue":1,"viewWindowMode":"pretty","viewWindow":{"max":100,"min":1}},"backgroundColor":{"fill":"white","stroke":"#666","strokeWidth":0},"chartArea":{"backgroundColor":{"stroke":"black","strokeWidth":1},"height":"auto","left":"auto","top":"auto","width":"auto"},"colors":["red","#004411"],"fontSize":12,"fontName":"Arial","title":"Title","titleTextStyle":{"color":"black","fontName":"Arial","fontSize":18,"bold":false,"italic":false},"enableInteractivity":true,"forceIFrame":false,"height":500,"width":700}', $js); |
332 | 332 | } |
@@ -16,16 +16,16 @@ |
||
16 | 16 | $chart->getOptions()->setTitle('title')->setTitlePosition('in'); |
17 | 17 | $chart->getData()->setArrayToDataTable([ |
18 | 18 | ['Time of Day', 'Motivation Level', ['role' => 'annotation'], 'Energy Level', ['role' => 'annotation']], |
19 | - [['v' => [8, 0, 0], 'f' => '8 am'], 1, '1', 0.25, '0.2'], |
|
20 | - [['v' => [9, 0, 0], 'f' => '9 am'], 2, '2', 0.5, '0.5'], |
|
21 | - [['v' => [10, 0, 0], 'f' => '10 am'], 3, '3', 1, '1'], |
|
22 | - [['v' => [11, 0, 0], 'f' => '11 am'], 4, '4', 2.25, '2'], |
|
23 | - [['v' => [12, 0, 0], 'f' => '12 am'], 5, '5', 2.25, '2'], |
|
24 | - [['v' => [13, 0, 0], 'f' => '1 pm'], 6, '6', 3, '3'], |
|
25 | - [['v' => [14, 0, 0], 'f' => '2 pm'], 7, '7', 3.25, '3'], |
|
26 | - [['v' => [15, 0, 0], 'f' => '3 pm'], 8, '8', 5, '5'], |
|
27 | - [['v' => [16, 0, 0], 'f' => '4 pm'], 9, '9', 6.5, '6'], |
|
28 | - [['v' => [17, 0, 0], 'f' => '5 pm'], 10, '10', 10, '10'] |
|
19 | + [['v' => [8, 0, 0], 'f' => '8 am'], 1, '1', 0.25, '0.2'], |
|
20 | + [['v' => [9, 0, 0], 'f' => '9 am'], 2, '2', 0.5, '0.5'], |
|
21 | + [['v' => [10, 0, 0], 'f' => '10 am'], 3, '3', 1, '1'], |
|
22 | + [['v' => [11, 0, 0], 'f' => '11 am'], 4, '4', 2.25, '2'], |
|
23 | + [['v' => [12, 0, 0], 'f' => '12 am'], 5, '5', 2.25, '2'], |
|
24 | + [['v' => [13, 0, 0], 'f' => '1 pm'], 6, '6', 3, '3'], |
|
25 | + [['v' => [14, 0, 0], 'f' => '2 pm'], 7, '7', 3.25, '3'], |
|
26 | + [['v' => [15, 0, 0], 'f' => '3 pm'], 8, '8', 5, '5'], |
|
27 | + [['v' => [16, 0, 0], 'f' => '4 pm'], 9, '9', 6.5, '6'], |
|
28 | + [['v' => [17, 0, 0], 'f' => '5 pm'], 10, '10', 10, '10'] |
|
29 | 29 | ]); |
30 | 30 | |
31 | 31 | $chart->startDraw(); |