@@ -15,25 +15,25 @@ |
||
| 15 | 15 | * |
| 16 | 16 | * @return string |
| 17 | 17 | */ |
| 18 | - public function render( $flags = null ) |
|
| 18 | + public function render($flags = null) |
|
| 19 | 19 | { |
| 20 | 20 | $dom = new \DOMDocument(); |
| 21 | 21 | |
| 22 | 22 | // Render canvas HTML element |
| 23 | - $canvas = $dom->createElement( 'canvas' ); |
|
| 24 | - $canvas->setAttribute( 'id', $this->chart->getId() ); |
|
| 23 | + $canvas = $dom->createElement('canvas'); |
|
| 24 | + $canvas->setAttribute('id', $this->chart->getId()); |
|
| 25 | 25 | |
| 26 | 26 | // Add title, height and width if applicable |
| 27 | - if( $this->chart->getTitle() ) $canvas->setAttribute( 'title', $this->chart->getTitle() ); |
|
| 28 | - if( $this->chart->getHeight() ) $canvas->setAttribute( 'height', $this->chart->getHeight() ); |
|
| 29 | - if( $this->chart->getWidth() ) $canvas->setAttribute( 'width', $this->chart->getWidth() ); |
|
| 27 | + if ($this->chart->getTitle()) $canvas->setAttribute('title', $this->chart->getTitle()); |
|
| 28 | + if ($this->chart->getHeight()) $canvas->setAttribute('height', $this->chart->getHeight()); |
|
| 29 | + if ($this->chart->getWidth()) $canvas->setAttribute('width', $this->chart->getWidth()); |
|
| 30 | 30 | |
| 31 | - $dom->appendChild( $canvas ); |
|
| 31 | + $dom->appendChild($canvas); |
|
| 32 | 32 | |
| 33 | 33 | // Render JavaScript |
| 34 | - $scriptRenderer = new JavaScript( $this->chart ); |
|
| 35 | - $script = $dom->createElement( 'script', $scriptRenderer->render( $flags ) ); |
|
| 36 | - $dom->appendChild( $script ); |
|
| 34 | + $scriptRenderer = new JavaScript($this->chart); |
|
| 35 | + $script = $dom->createElement('script', $scriptRenderer->render($flags)); |
|
| 36 | + $dom->appendChild($script); |
|
| 37 | 37 | |
| 38 | 38 | return $dom->saveHTML(); |
| 39 | 39 | } |
@@ -24,9 +24,15 @@ |
||
| 24 | 24 | $canvas->setAttribute( 'id', $this->chart->getId() ); |
| 25 | 25 | |
| 26 | 26 | // Add title, height and width if applicable |
| 27 | - if( $this->chart->getTitle() ) $canvas->setAttribute( 'title', $this->chart->getTitle() ); |
|
| 28 | - if( $this->chart->getHeight() ) $canvas->setAttribute( 'height', $this->chart->getHeight() ); |
|
| 29 | - if( $this->chart->getWidth() ) $canvas->setAttribute( 'width', $this->chart->getWidth() ); |
|
| 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 | + } |
|
| 30 | 36 | |
| 31 | 37 | $dom->appendChild( $canvas ); |
| 32 | 38 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @param Chart $chart |
| 16 | 16 | */ |
| 17 | - public function __construct( Chart $chart ); |
|
| 17 | + public function __construct(Chart $chart); |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Render the chart with the current strategy, returning a string. |
@@ -23,5 +23,5 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return string |
| 25 | 25 | */ |
| 26 | - public function render( $flags = null ); |
|
| 26 | + public function render($flags = null); |
|
| 27 | 27 | } |
| 28 | 28 | \ No newline at end of file |
@@ -16,6 +16,6 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | public function jsonSerialize() |
| 18 | 18 | { |
| 19 | - return Json::encode( $this->data ); |
|
| 19 | + return Json::encode($this->data); |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |
@@ -13,12 +13,12 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * The internal type of chart. |
| 15 | 15 | */ |
| 16 | - const TYPE = null; |
|
| 16 | + const TYPE = null; |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * The list of models that should be used for this chart type. |
| 20 | 20 | */ |
| 21 | - const MODEL = [ |
|
| 21 | + const MODEL = [ |
|
| 22 | 22 | 'dataset' => DataSet::class, |
| 23 | 23 | 'options' => Options::class |
| 24 | 24 | ]; |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function getId() |
| 65 | 65 | { |
| 66 | - if( is_null( $this->id ) ) { |
|
| 67 | - $this->id = uniqid( 'chart' ); |
|
| 66 | + if (is_null($this->id)) { |
|
| 67 | + $this->id = uniqid('chart'); |
|
| 68 | 68 | } |
| 69 | 69 | return $this->id; |
| 70 | 70 | } |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return Chart |
| 76 | 76 | */ |
| 77 | - public function setId( $id ) |
|
| 77 | + public function setId($id) |
|
| 78 | 78 | { |
| 79 | - $this->id = strval( $id ); |
|
| 79 | + $this->id = strval($id); |
|
| 80 | 80 | |
| 81 | 81 | return $this; |
| 82 | 82 | } |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @return Chart |
| 96 | 96 | */ |
| 97 | - public function setHeight( $height ) |
|
| 97 | + public function setHeight($height) |
|
| 98 | 98 | { |
| 99 | - $this->height = intval( $height ); |
|
| 99 | + $this->height = intval($height); |
|
| 100 | 100 | |
| 101 | 101 | return $this; |
| 102 | 102 | } |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return Chart |
| 116 | 116 | */ |
| 117 | - public function setWidth( $width ) |
|
| 117 | + public function setWidth($width) |
|
| 118 | 118 | { |
| 119 | - $this->width = intval( $width ); |
|
| 119 | + $this->width = intval($width); |
|
| 120 | 120 | |
| 121 | 121 | return $this; |
| 122 | 122 | } |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * @return Chart |
| 136 | 136 | */ |
| 137 | - public function setTitle( $title ) |
|
| 137 | + public function setTitle($title) |
|
| 138 | 138 | { |
| 139 | - $this->title = strval( $title ); |
|
| 139 | + $this->title = strval($title); |
|
| 140 | 140 | |
| 141 | 141 | return $this; |
| 142 | 142 | } |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function labels() |
| 148 | 148 | { |
| 149 | - if( is_null( $this->labels ) ) { |
|
| 150 | - $this->labels = new LabelsCollection(); |
|
| 149 | + if (is_null($this->labels)) { |
|
| 150 | + $this->labels = new LabelsCollection(); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | return $this->labels; |
@@ -158,9 +158,9 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @return $this |
| 160 | 160 | */ |
| 161 | - public function addLabel( $label ) |
|
| 161 | + public function addLabel($label) |
|
| 162 | 162 | { |
| 163 | - $this->labels()->append( $label ); |
|
| 163 | + $this->labels()->append($label); |
|
| 164 | 164 | |
| 165 | 165 | return $this; |
| 166 | 166 | } |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @return string|bool |
| 172 | 172 | */ |
| 173 | - public function getLabel( $offset ) |
|
| 173 | + public function getLabel($offset) |
|
| 174 | 174 | { |
| 175 | - return $this->labels()->offsetGet( $offset ); |
|
| 175 | + return $this->labels()->offsetGet($offset); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function dataSets() |
| 182 | 182 | { |
| 183 | - if( is_null( $this->dataSets ) ) { |
|
| 184 | - $this->dataSets = new DataSetCollection(); |
|
| 183 | + if (is_null($this->dataSets)) { |
|
| 184 | + $this->dataSets = new DataSetCollection(); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | return $this->dataSets; |
@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | * |
| 193 | 193 | * @return $this |
| 194 | 194 | */ |
| 195 | - public function addDataSet( DataSet $dataSet ) |
|
| 195 | + public function addDataSet(DataSet $dataSet) |
|
| 196 | 196 | { |
| 197 | - $this->dataSets()->append( $dataSet->setOwner( $this ) ); |
|
| 197 | + $this->dataSets()->append($dataSet->setOwner($this)); |
|
| 198 | 198 | |
| 199 | 199 | return $this; |
| 200 | 200 | } |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @return DataSet|bool |
| 206 | 206 | */ |
| 207 | - public function getDataSet( $offset ) |
|
| 207 | + public function getDataSet($offset) |
|
| 208 | 208 | { |
| 209 | - return $this->dataSets()->offsetGet( $offset ); |
|
| 209 | + return $this->dataSets()->offsetGet($offset); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -214,11 +214,11 @@ discard block |
||
| 214 | 214 | * |
| 215 | 215 | * @return string |
| 216 | 216 | */ |
| 217 | - public function render( $pretty = false ) |
|
| 217 | + public function render($pretty = false) |
|
| 218 | 218 | { |
| 219 | - $renderer = new Html( $this ); |
|
| 219 | + $renderer = new Html($this); |
|
| 220 | 220 | |
| 221 | - return $renderer->render( !!$pretty ? $renderer::RENDER_PRETTY : null ); |
|
| 221 | + return $renderer->render(!!$pretty ? $renderer::RENDER_PRETTY : null); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | public function createDataSet() |
| 228 | 228 | { |
| 229 | - $datasetClass = static::MODEL['dataset']; |
|
| 229 | + $datasetClass = static::MODEL[ 'dataset' ]; |
|
| 230 | 230 | return new $datasetClass(); |
| 231 | 231 | } |
| 232 | 232 | |
@@ -235,9 +235,9 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | public function options() |
| 237 | 237 | { |
| 238 | - if( is_null( $this->options ) ) { |
|
| 239 | - $optionsClass = static::MODEL['options']; |
|
| 240 | - $this->options = new $optionsClass( $this ); |
|
| 238 | + if (is_null($this->options)) { |
|
| 239 | + $optionsClass = static::MODEL[ 'options' ]; |
|
| 240 | + $this->options = new $optionsClass($this); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | return $this->options; |
@@ -16,10 +16,10 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | public function getArrayCopy() |
| 18 | 18 | { |
| 19 | - $rows = []; |
|
| 20 | - foreach( $this->data as $row ) { |
|
| 19 | + $rows = [ ]; |
|
| 20 | + foreach ($this->data as $row) { |
|
| 21 | 21 | /** @var DataSet $row */ |
| 22 | - $rows[] = $row->getArrayCopy(); |
|
| 22 | + $rows[ ] = $row->getArrayCopy(); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | return $rows; |
@@ -30,6 +30,6 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function jsonSerialize() |
| 32 | 32 | { |
| 33 | - return Json::encode( $this->getArrayCopy() ); |
|
| 33 | + return Json::encode($this->getArrayCopy()); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function getLayout() |
| 63 | 63 | { |
| 64 | - if( is_null( $this->layout ) ) { |
|
| 65 | - $this->layout = new Layout(); |
|
| 64 | + if (is_null($this->layout)) { |
|
| 65 | + $this->layout = new Layout(); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | return $this->layout; |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function getTitle() |
| 75 | 75 | { |
| 76 | - if( is_null( $this->title ) ) { |
|
| 76 | + if (is_null($this->title)) { |
|
| 77 | 77 | $this->title = new Title(); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function getHover() |
| 87 | 87 | { |
| 88 | - if( is_null( $this->hover ) ) { |
|
| 88 | + if (is_null($this->hover)) { |
|
| 89 | 89 | $this->hover = new Hover(); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function getScales() |
| 99 | 99 | { |
| 100 | - if( is_null( $this->scales ) ) { |
|
| 100 | + if (is_null($this->scales)) { |
|
| 101 | 101 | $this->scales = new Scales(); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function getAnimation() |
| 111 | 111 | { |
| 112 | - if( is_null( $this->animation ) ) { |
|
| 112 | + if (is_null($this->animation)) { |
|
| 113 | 113 | $this->animation = new Animation(); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function getLegend() |
| 123 | 123 | { |
| 124 | - if( is_null( $this->legend ) ) { |
|
| 124 | + if (is_null($this->legend)) { |
|
| 125 | 125 | $this->legend = new Legend(); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function getTooltips() |
| 135 | 135 | { |
| 136 | - if( is_null( $this->tooltips ) ) { |
|
| 136 | + if (is_null($this->tooltips)) { |
|
| 137 | 137 | $this->tooltips = new Tooltips(); |
| 138 | 138 | } |
| 139 | 139 | |
@@ -145,6 +145,6 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public function jsonSerialize() |
| 147 | 147 | { |
| 148 | - return Json::encode( $this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ] ); |
|
| 148 | + return Json::encode($this->getArrayCopy(), false, [ 'enableJsonExprFinder' => true ]); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | \ No newline at end of file |
@@ -18,9 +18,9 @@ |
||
| 18 | 18 | * |
| 19 | 19 | * @return $this |
| 20 | 20 | */ |
| 21 | - public function setOwner( ChartInterface $chart ) |
|
| 21 | + public function setOwner(ChartInterface $chart) |
|
| 22 | 22 | { |
| 23 | - $this->owner = $chart; |
|
| 23 | + $this->owner = $chart; |
|
| 24 | 24 | |
| 25 | 25 | return $this; |
| 26 | 26 | } |
@@ -16,6 +16,6 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | public function jsonSerialize() |
| 18 | 18 | { |
| 19 | - return Json::encode( $this->data ); |
|
| 19 | + return Json::encode($this->data); |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |