@@ -14,113 +14,113 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class Animation implements ArraySerializableInterface, JsonSerializable |
| 16 | 16 | { |
| 17 | - use ArraySerializable; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * @var int |
|
| 21 | - */ |
|
| 22 | - private $duration; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - private $easing; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var Expr |
|
| 31 | - */ |
|
| 32 | - private $onProgress; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var Expr |
|
| 36 | - */ |
|
| 37 | - private $onComplete; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @return int |
|
| 41 | - */ |
|
| 42 | - public function getDuration() |
|
| 43 | - { |
|
| 44 | - return $this->duration; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @param int $duration |
|
| 49 | - * |
|
| 50 | - * @return $this |
|
| 51 | - */ |
|
| 52 | - public function setDuration($duration) |
|
| 53 | - { |
|
| 54 | - $this->duration = $duration; |
|
| 55 | - |
|
| 56 | - return $this; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @return string |
|
| 61 | - */ |
|
| 62 | - public function getEasing() |
|
| 63 | - { |
|
| 64 | - return $this->easing; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @param string $easing |
|
| 69 | - * |
|
| 70 | - * @return $this |
|
| 71 | - */ |
|
| 72 | - public function setEasing($easing) |
|
| 73 | - { |
|
| 74 | - $this->easing = $easing; |
|
| 75 | - |
|
| 76 | - return $this; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @return Expr |
|
| 81 | - */ |
|
| 82 | - public function getOnProgress() |
|
| 83 | - { |
|
| 84 | - return $this->onProgress; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @param string $onProgress |
|
| 89 | - * |
|
| 90 | - * @return $this |
|
| 91 | - */ |
|
| 92 | - public function setOnProgress($onProgress) |
|
| 93 | - { |
|
| 94 | - $this->onProgress = new Expr(strval($onProgress)); |
|
| 95 | - |
|
| 96 | - return $this; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @return Expr |
|
| 101 | - */ |
|
| 102 | - public function getOnComplete() |
|
| 103 | - { |
|
| 104 | - return $this->onComplete; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * @param string $onComplete |
|
| 109 | - * |
|
| 110 | - * @return $this |
|
| 111 | - */ |
|
| 112 | - public function setOnComplete($onComplete) |
|
| 113 | - { |
|
| 114 | - $this->onComplete = new Expr(strval($onComplete)); |
|
| 115 | - |
|
| 116 | - return $this; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @return array |
|
| 121 | - */ |
|
| 122 | - public function jsonSerialize() |
|
| 123 | - { |
|
| 124 | - return $this->getArrayCopy(); |
|
| 125 | - } |
|
| 17 | + use ArraySerializable; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * @var int |
|
| 21 | + */ |
|
| 22 | + private $duration; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + private $easing; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var Expr |
|
| 31 | + */ |
|
| 32 | + private $onProgress; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var Expr |
|
| 36 | + */ |
|
| 37 | + private $onComplete; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @return int |
|
| 41 | + */ |
|
| 42 | + public function getDuration() |
|
| 43 | + { |
|
| 44 | + return $this->duration; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @param int $duration |
|
| 49 | + * |
|
| 50 | + * @return $this |
|
| 51 | + */ |
|
| 52 | + public function setDuration($duration) |
|
| 53 | + { |
|
| 54 | + $this->duration = $duration; |
|
| 55 | + |
|
| 56 | + return $this; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @return string |
|
| 61 | + */ |
|
| 62 | + public function getEasing() |
|
| 63 | + { |
|
| 64 | + return $this->easing; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @param string $easing |
|
| 69 | + * |
|
| 70 | + * @return $this |
|
| 71 | + */ |
|
| 72 | + public function setEasing($easing) |
|
| 73 | + { |
|
| 74 | + $this->easing = $easing; |
|
| 75 | + |
|
| 76 | + return $this; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @return Expr |
|
| 81 | + */ |
|
| 82 | + public function getOnProgress() |
|
| 83 | + { |
|
| 84 | + return $this->onProgress; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @param string $onProgress |
|
| 89 | + * |
|
| 90 | + * @return $this |
|
| 91 | + */ |
|
| 92 | + public function setOnProgress($onProgress) |
|
| 93 | + { |
|
| 94 | + $this->onProgress = new Expr(strval($onProgress)); |
|
| 95 | + |
|
| 96 | + return $this; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @return Expr |
|
| 101 | + */ |
|
| 102 | + public function getOnComplete() |
|
| 103 | + { |
|
| 104 | + return $this->onComplete; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * @param string $onComplete |
|
| 109 | + * |
|
| 110 | + * @return $this |
|
| 111 | + */ |
|
| 112 | + public function setOnComplete($onComplete) |
|
| 113 | + { |
|
| 114 | + $this->onComplete = new Expr(strval($onComplete)); |
|
| 115 | + |
|
| 116 | + return $this; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @return array |
|
| 121 | + */ |
|
| 122 | + public function jsonSerialize() |
|
| 123 | + { |
|
| 124 | + return $this->getArrayCopy(); |
|
| 125 | + } |
|
| 126 | 126 | } |
@@ -11,39 +11,39 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Html extends Renderer |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Renders the necessary HTML for the chart to function in the frontend. |
|
| 16 | - * |
|
| 17 | - * @param int|null $flags |
|
| 18 | - * |
|
| 19 | - * @return string |
|
| 20 | - */ |
|
| 21 | - public function render($flags = null) |
|
| 22 | - { |
|
| 23 | - $dom = new DOMDocument(); |
|
| 24 | - |
|
| 25 | - // Render canvas HTML element |
|
| 26 | - $canvas = $dom->createElement('canvas'); |
|
| 27 | - $canvas->setAttribute('id', $this->chart->getId()); |
|
| 28 | - |
|
| 29 | - // Add title, height and width if applicable |
|
| 30 | - if ($this->chart->getTitle()) { |
|
| 31 | - $canvas->setAttribute('title', $this->chart->getTitle()); |
|
| 32 | - } |
|
| 33 | - if ($this->chart->getHeight()) { |
|
| 34 | - $canvas->setAttribute('height', $this->chart->getHeight()); |
|
| 35 | - } |
|
| 36 | - if ($this->chart->getWidth()) { |
|
| 37 | - $canvas->setAttribute('width', $this->chart->getWidth()); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - $dom->appendChild($canvas); |
|
| 41 | - |
|
| 42 | - // Render JavaScript |
|
| 43 | - $scriptRenderer = new JavaScript($this->chart); |
|
| 44 | - $script = $dom->createElement('script', $scriptRenderer->render($flags)); |
|
| 45 | - $dom->appendChild($script); |
|
| 46 | - |
|
| 47 | - return $dom->saveHTML(); |
|
| 48 | - } |
|
| 14 | + /** |
|
| 15 | + * Renders the necessary HTML for the chart to function in the frontend. |
|
| 16 | + * |
|
| 17 | + * @param int|null $flags |
|
| 18 | + * |
|
| 19 | + * @return string |
|
| 20 | + */ |
|
| 21 | + public function render($flags = null) |
|
| 22 | + { |
|
| 23 | + $dom = new DOMDocument(); |
|
| 24 | + |
|
| 25 | + // Render canvas HTML element |
|
| 26 | + $canvas = $dom->createElement('canvas'); |
|
| 27 | + $canvas->setAttribute('id', $this->chart->getId()); |
|
| 28 | + |
|
| 29 | + // Add title, height and width if applicable |
|
| 30 | + if ($this->chart->getTitle()) { |
|
| 31 | + $canvas->setAttribute('title', $this->chart->getTitle()); |
|
| 32 | + } |
|
| 33 | + if ($this->chart->getHeight()) { |
|
| 34 | + $canvas->setAttribute('height', $this->chart->getHeight()); |
|
| 35 | + } |
|
| 36 | + if ($this->chart->getWidth()) { |
|
| 37 | + $canvas->setAttribute('width', $this->chart->getWidth()); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + $dom->appendChild($canvas); |
|
| 41 | + |
|
| 42 | + // Render JavaScript |
|
| 43 | + $scriptRenderer = new JavaScript($this->chart); |
|
| 44 | + $script = $dom->createElement('script', $scriptRenderer->render($flags)); |
|
| 45 | + $dom->appendChild($script); |
|
| 46 | + |
|
| 47 | + return $dom->saveHTML(); |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -10,31 +10,31 @@ |
||
| 10 | 10 | trait NumberUtils |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @param array $input |
|
| 15 | - * |
|
| 16 | - * @return array |
|
| 17 | - */ |
|
| 18 | - public function recursiveToFloat(array $input) |
|
| 19 | - { |
|
| 20 | - array_walk_recursive($input, function (&$value) { |
|
| 21 | - $value = floatval($value); |
|
| 22 | - }); |
|
| 13 | + /** |
|
| 14 | + * @param array $input |
|
| 15 | + * |
|
| 16 | + * @return array |
|
| 17 | + */ |
|
| 18 | + public function recursiveToFloat(array $input) |
|
| 19 | + { |
|
| 20 | + array_walk_recursive($input, function (&$value) { |
|
| 21 | + $value = floatval($value); |
|
| 22 | + }); |
|
| 23 | 23 | |
| 24 | - return $input; |
|
| 25 | - } |
|
| 24 | + return $input; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @param array $input |
|
| 29 | - * |
|
| 30 | - * @return array |
|
| 31 | - */ |
|
| 32 | - public function recursiveToInt(array $input) |
|
| 33 | - { |
|
| 34 | - array_walk_recursive($input, function (&$value) { |
|
| 35 | - $value = intval($value); |
|
| 36 | - }); |
|
| 27 | + /** |
|
| 28 | + * @param array $input |
|
| 29 | + * |
|
| 30 | + * @return array |
|
| 31 | + */ |
|
| 32 | + public function recursiveToInt(array $input) |
|
| 33 | + { |
|
| 34 | + array_walk_recursive($input, function (&$value) { |
|
| 35 | + $value = intval($value); |
|
| 36 | + }); |
|
| 37 | 37 | |
| 38 | - return $input; |
|
| 39 | - } |
|
| 38 | + return $input; |
|
| 39 | + } |
|
| 40 | 40 | } |
@@ -9,17 +9,17 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | trait StringUtils |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * @param array $input |
|
| 14 | - * |
|
| 15 | - * @return array |
|
| 16 | - */ |
|
| 17 | - public function recursiveToString(array $input) |
|
| 18 | - { |
|
| 19 | - array_walk_recursive($input, function (&$value) { |
|
| 20 | - $value = strval($value); |
|
| 21 | - }); |
|
| 12 | + /** |
|
| 13 | + * @param array $input |
|
| 14 | + * |
|
| 15 | + * @return array |
|
| 16 | + */ |
|
| 17 | + public function recursiveToString(array $input) |
|
| 18 | + { |
|
| 19 | + array_walk_recursive($input, function (&$value) { |
|
| 20 | + $value = strval($value); |
|
| 21 | + }); |
|
| 22 | 22 | |
| 23 | - return $input; |
|
| 24 | - } |
|
| 23 | + return $input; |
|
| 24 | + } |
|
| 25 | 25 | } |
@@ -15,325 +15,325 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class GridLines implements ArraySerializableInterface, JsonSerializable |
| 17 | 17 | { |
| 18 | - use ArraySerializable; |
|
| 19 | - use StringUtils; |
|
| 20 | - use NumberUtils; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @var bool |
|
| 24 | - */ |
|
| 25 | - private $display; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @var string|string[] |
|
| 29 | - */ |
|
| 30 | - private $color; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @var float[]|null |
|
| 34 | - */ |
|
| 35 | - private $borderDash; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @var float |
|
| 39 | - */ |
|
| 40 | - private $borderDashOffset; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var int|int[] |
|
| 44 | - */ |
|
| 45 | - private $lineWidth; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var bool |
|
| 49 | - */ |
|
| 50 | - private $drawBorder; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @var bool |
|
| 54 | - */ |
|
| 55 | - private $drawOnChartArea; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @var bool |
|
| 59 | - */ |
|
| 60 | - private $drawTicks; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @var int |
|
| 64 | - */ |
|
| 65 | - private $tickMarkLength; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @var int |
|
| 69 | - */ |
|
| 70 | - private $zeroLineWidth; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @var string |
|
| 74 | - */ |
|
| 75 | - private $zeroLineColor; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * @var bool |
|
| 79 | - */ |
|
| 80 | - private $offsetGridLines; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * @return bool |
|
| 84 | - */ |
|
| 85 | - public function isDisplay() |
|
| 86 | - { |
|
| 87 | - return $this->display; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @param bool $display |
|
| 92 | - * |
|
| 93 | - * @return $this |
|
| 94 | - */ |
|
| 95 | - public function setDisplay($display) |
|
| 96 | - { |
|
| 97 | - $this->display = $display; |
|
| 98 | - |
|
| 99 | - return $this; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @return string|string[] |
|
| 104 | - */ |
|
| 105 | - public function getColor() |
|
| 106 | - { |
|
| 107 | - return $this->color; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * @param string|string[] $color |
|
| 112 | - * |
|
| 113 | - * @return $this |
|
| 114 | - */ |
|
| 115 | - public function setColor($color) |
|
| 116 | - { |
|
| 117 | - if (is_array($color)) { |
|
| 118 | - $this->color = $this->recursiveToString($color); |
|
| 119 | - } else { |
|
| 120 | - $this->color = is_null($color) ? null : strval($color); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - return $this; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * @return float[]|null |
|
| 128 | - */ |
|
| 129 | - public function getBorderDash() |
|
| 130 | - { |
|
| 131 | - return $this->borderDash; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * @param float[] $borderDash |
|
| 136 | - * |
|
| 137 | - * @return $this |
|
| 138 | - */ |
|
| 139 | - public function setBorderDash($borderDash) |
|
| 140 | - { |
|
| 141 | - if (is_array($borderDash)) { |
|
| 142 | - $this->borderDash = $this->recursiveToFloat($borderDash); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - return $this; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @return float |
|
| 150 | - */ |
|
| 151 | - public function getBorderDashOffset() |
|
| 152 | - { |
|
| 153 | - return $this->borderDashOffset; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * @param float $borderDashOffset |
|
| 158 | - * |
|
| 159 | - * @return $this |
|
| 160 | - */ |
|
| 161 | - public function setBorderDashOffset($borderDashOffset) |
|
| 162 | - { |
|
| 163 | - $this->borderDashOffset = floatval($borderDashOffset); |
|
| 164 | - |
|
| 165 | - return $this; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * @return int|int[] |
|
| 170 | - */ |
|
| 171 | - public function getLineWidth() |
|
| 172 | - { |
|
| 173 | - return $this->lineWidth; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * @param int|int[] $lineWidth |
|
| 178 | - * |
|
| 179 | - * @return $this |
|
| 180 | - */ |
|
| 181 | - public function setLineWidth($lineWidth) |
|
| 182 | - { |
|
| 183 | - if (is_array($lineWidth)) { |
|
| 184 | - $this->lineWidth = $this->recursiveToInt($lineWidth); |
|
| 185 | - } else { |
|
| 186 | - $this->lineWidth = is_null($lineWidth) ? null : intval($lineWidth); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - return $this; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * @return bool |
|
| 194 | - */ |
|
| 195 | - public function isDrawBorder() |
|
| 196 | - { |
|
| 197 | - return $this->drawBorder; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * @param bool $drawBorder |
|
| 202 | - * |
|
| 203 | - * @return $this |
|
| 204 | - */ |
|
| 205 | - public function setDrawBorder($drawBorder) |
|
| 206 | - { |
|
| 207 | - $this->drawBorder = boolval($drawBorder); |
|
| 208 | - |
|
| 209 | - return $this; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * @return bool |
|
| 214 | - */ |
|
| 215 | - public function isDrawOnChartArea() |
|
| 216 | - { |
|
| 217 | - return $this->drawOnChartArea; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * @param bool $drawOnChartArea |
|
| 222 | - * |
|
| 223 | - * @return $this |
|
| 224 | - */ |
|
| 225 | - public function setDrawOnChartArea($drawOnChartArea) |
|
| 226 | - { |
|
| 227 | - $this->drawOnChartArea = boolval($drawOnChartArea); |
|
| 228 | - |
|
| 229 | - return $this; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * @return bool |
|
| 234 | - */ |
|
| 235 | - public function isDrawTicks() |
|
| 236 | - { |
|
| 237 | - return $this->drawTicks; |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * @param bool $drawTicks |
|
| 242 | - * |
|
| 243 | - * @return $this |
|
| 244 | - */ |
|
| 245 | - public function setDrawTicks($drawTicks) |
|
| 246 | - { |
|
| 247 | - $this->drawTicks = boolval($drawTicks); |
|
| 248 | - |
|
| 249 | - return $this; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * @return int |
|
| 254 | - */ |
|
| 255 | - public function getTickMarkLength() |
|
| 256 | - { |
|
| 257 | - return $this->tickMarkLength; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * @param int $tickMarkLength |
|
| 262 | - * |
|
| 263 | - * @return $this |
|
| 264 | - */ |
|
| 265 | - public function setTickMarkLength($tickMarkLength) |
|
| 266 | - { |
|
| 267 | - $this->tickMarkLength = intval($tickMarkLength); |
|
| 268 | - |
|
| 269 | - return $this; |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * @return int |
|
| 274 | - */ |
|
| 275 | - public function getZeroLineWidth() |
|
| 276 | - { |
|
| 277 | - return $this->zeroLineWidth; |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * @param int $zeroLineWidth |
|
| 282 | - * |
|
| 283 | - * @return $this |
|
| 284 | - */ |
|
| 285 | - public function setZeroLineWidth($zeroLineWidth) |
|
| 286 | - { |
|
| 287 | - $this->zeroLineWidth = intval($zeroLineWidth); |
|
| 288 | - |
|
| 289 | - return $this; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * @return string |
|
| 294 | - */ |
|
| 295 | - public function getZeroLineColor() |
|
| 296 | - { |
|
| 297 | - return $this->zeroLineColor; |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - /** |
|
| 301 | - * @param string $zeroLineColor |
|
| 302 | - * |
|
| 303 | - * @return $this |
|
| 304 | - */ |
|
| 305 | - public function setZeroLineColor($zeroLineColor) |
|
| 306 | - { |
|
| 307 | - $this->zeroLineColor = is_null($zeroLineColor) ? null : strval($zeroLineColor); |
|
| 308 | - |
|
| 309 | - return $this; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * @return bool |
|
| 314 | - */ |
|
| 315 | - public function isOffsetGridLines() |
|
| 316 | - { |
|
| 317 | - return $this->offsetGridLines; |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - /** |
|
| 321 | - * @param bool $offsetGridLines |
|
| 322 | - * |
|
| 323 | - * @return $this |
|
| 324 | - */ |
|
| 325 | - public function setOffsetGridLines($offsetGridLines) |
|
| 326 | - { |
|
| 327 | - $this->offsetGridLines = boolval($offsetGridLines); |
|
| 328 | - |
|
| 329 | - return $this; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - /** |
|
| 333 | - * @return array |
|
| 334 | - */ |
|
| 335 | - public function jsonSerialize() |
|
| 336 | - { |
|
| 337 | - return $this->getArrayCopy(); |
|
| 338 | - } |
|
| 18 | + use ArraySerializable; |
|
| 19 | + use StringUtils; |
|
| 20 | + use NumberUtils; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @var bool |
|
| 24 | + */ |
|
| 25 | + private $display; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @var string|string[] |
|
| 29 | + */ |
|
| 30 | + private $color; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @var float[]|null |
|
| 34 | + */ |
|
| 35 | + private $borderDash; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @var float |
|
| 39 | + */ |
|
| 40 | + private $borderDashOffset; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var int|int[] |
|
| 44 | + */ |
|
| 45 | + private $lineWidth; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var bool |
|
| 49 | + */ |
|
| 50 | + private $drawBorder; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @var bool |
|
| 54 | + */ |
|
| 55 | + private $drawOnChartArea; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @var bool |
|
| 59 | + */ |
|
| 60 | + private $drawTicks; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @var int |
|
| 64 | + */ |
|
| 65 | + private $tickMarkLength; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @var int |
|
| 69 | + */ |
|
| 70 | + private $zeroLineWidth; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @var string |
|
| 74 | + */ |
|
| 75 | + private $zeroLineColor; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * @var bool |
|
| 79 | + */ |
|
| 80 | + private $offsetGridLines; |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * @return bool |
|
| 84 | + */ |
|
| 85 | + public function isDisplay() |
|
| 86 | + { |
|
| 87 | + return $this->display; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @param bool $display |
|
| 92 | + * |
|
| 93 | + * @return $this |
|
| 94 | + */ |
|
| 95 | + public function setDisplay($display) |
|
| 96 | + { |
|
| 97 | + $this->display = $display; |
|
| 98 | + |
|
| 99 | + return $this; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @return string|string[] |
|
| 104 | + */ |
|
| 105 | + public function getColor() |
|
| 106 | + { |
|
| 107 | + return $this->color; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * @param string|string[] $color |
|
| 112 | + * |
|
| 113 | + * @return $this |
|
| 114 | + */ |
|
| 115 | + public function setColor($color) |
|
| 116 | + { |
|
| 117 | + if (is_array($color)) { |
|
| 118 | + $this->color = $this->recursiveToString($color); |
|
| 119 | + } else { |
|
| 120 | + $this->color = is_null($color) ? null : strval($color); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + return $this; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * @return float[]|null |
|
| 128 | + */ |
|
| 129 | + public function getBorderDash() |
|
| 130 | + { |
|
| 131 | + return $this->borderDash; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * @param float[] $borderDash |
|
| 136 | + * |
|
| 137 | + * @return $this |
|
| 138 | + */ |
|
| 139 | + public function setBorderDash($borderDash) |
|
| 140 | + { |
|
| 141 | + if (is_array($borderDash)) { |
|
| 142 | + $this->borderDash = $this->recursiveToFloat($borderDash); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + return $this; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * @return float |
|
| 150 | + */ |
|
| 151 | + public function getBorderDashOffset() |
|
| 152 | + { |
|
| 153 | + return $this->borderDashOffset; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * @param float $borderDashOffset |
|
| 158 | + * |
|
| 159 | + * @return $this |
|
| 160 | + */ |
|
| 161 | + public function setBorderDashOffset($borderDashOffset) |
|
| 162 | + { |
|
| 163 | + $this->borderDashOffset = floatval($borderDashOffset); |
|
| 164 | + |
|
| 165 | + return $this; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * @return int|int[] |
|
| 170 | + */ |
|
| 171 | + public function getLineWidth() |
|
| 172 | + { |
|
| 173 | + return $this->lineWidth; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * @param int|int[] $lineWidth |
|
| 178 | + * |
|
| 179 | + * @return $this |
|
| 180 | + */ |
|
| 181 | + public function setLineWidth($lineWidth) |
|
| 182 | + { |
|
| 183 | + if (is_array($lineWidth)) { |
|
| 184 | + $this->lineWidth = $this->recursiveToInt($lineWidth); |
|
| 185 | + } else { |
|
| 186 | + $this->lineWidth = is_null($lineWidth) ? null : intval($lineWidth); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + return $this; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * @return bool |
|
| 194 | + */ |
|
| 195 | + public function isDrawBorder() |
|
| 196 | + { |
|
| 197 | + return $this->drawBorder; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * @param bool $drawBorder |
|
| 202 | + * |
|
| 203 | + * @return $this |
|
| 204 | + */ |
|
| 205 | + public function setDrawBorder($drawBorder) |
|
| 206 | + { |
|
| 207 | + $this->drawBorder = boolval($drawBorder); |
|
| 208 | + |
|
| 209 | + return $this; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * @return bool |
|
| 214 | + */ |
|
| 215 | + public function isDrawOnChartArea() |
|
| 216 | + { |
|
| 217 | + return $this->drawOnChartArea; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * @param bool $drawOnChartArea |
|
| 222 | + * |
|
| 223 | + * @return $this |
|
| 224 | + */ |
|
| 225 | + public function setDrawOnChartArea($drawOnChartArea) |
|
| 226 | + { |
|
| 227 | + $this->drawOnChartArea = boolval($drawOnChartArea); |
|
| 228 | + |
|
| 229 | + return $this; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * @return bool |
|
| 234 | + */ |
|
| 235 | + public function isDrawTicks() |
|
| 236 | + { |
|
| 237 | + return $this->drawTicks; |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * @param bool $drawTicks |
|
| 242 | + * |
|
| 243 | + * @return $this |
|
| 244 | + */ |
|
| 245 | + public function setDrawTicks($drawTicks) |
|
| 246 | + { |
|
| 247 | + $this->drawTicks = boolval($drawTicks); |
|
| 248 | + |
|
| 249 | + return $this; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * @return int |
|
| 254 | + */ |
|
| 255 | + public function getTickMarkLength() |
|
| 256 | + { |
|
| 257 | + return $this->tickMarkLength; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * @param int $tickMarkLength |
|
| 262 | + * |
|
| 263 | + * @return $this |
|
| 264 | + */ |
|
| 265 | + public function setTickMarkLength($tickMarkLength) |
|
| 266 | + { |
|
| 267 | + $this->tickMarkLength = intval($tickMarkLength); |
|
| 268 | + |
|
| 269 | + return $this; |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * @return int |
|
| 274 | + */ |
|
| 275 | + public function getZeroLineWidth() |
|
| 276 | + { |
|
| 277 | + return $this->zeroLineWidth; |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * @param int $zeroLineWidth |
|
| 282 | + * |
|
| 283 | + * @return $this |
|
| 284 | + */ |
|
| 285 | + public function setZeroLineWidth($zeroLineWidth) |
|
| 286 | + { |
|
| 287 | + $this->zeroLineWidth = intval($zeroLineWidth); |
|
| 288 | + |
|
| 289 | + return $this; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * @return string |
|
| 294 | + */ |
|
| 295 | + public function getZeroLineColor() |
|
| 296 | + { |
|
| 297 | + return $this->zeroLineColor; |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + /** |
|
| 301 | + * @param string $zeroLineColor |
|
| 302 | + * |
|
| 303 | + * @return $this |
|
| 304 | + */ |
|
| 305 | + public function setZeroLineColor($zeroLineColor) |
|
| 306 | + { |
|
| 307 | + $this->zeroLineColor = is_null($zeroLineColor) ? null : strval($zeroLineColor); |
|
| 308 | + |
|
| 309 | + return $this; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * @return bool |
|
| 314 | + */ |
|
| 315 | + public function isOffsetGridLines() |
|
| 316 | + { |
|
| 317 | + return $this->offsetGridLines; |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + /** |
|
| 321 | + * @param bool $offsetGridLines |
|
| 322 | + * |
|
| 323 | + * @return $this |
|
| 324 | + */ |
|
| 325 | + public function setOffsetGridLines($offsetGridLines) |
|
| 326 | + { |
|
| 327 | + $this->offsetGridLines = boolval($offsetGridLines); |
|
| 328 | + |
|
| 329 | + return $this; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * @return array |
|
| 334 | + */ |
|
| 335 | + public function jsonSerialize() |
|
| 336 | + { |
|
| 337 | + return $this->getArrayCopy(); |
|
| 338 | + } |
|
| 339 | 339 | } |
@@ -12,31 +12,31 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class DataSetCollection extends ArrayAccess implements JsonSerializable |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @return array |
|
| 17 | - */ |
|
| 18 | - public function getArrayCopy() |
|
| 19 | - { |
|
| 20 | - $rows = []; |
|
| 21 | - foreach ($this->data as $row) { |
|
| 22 | - /** @var DataSet $row */ |
|
| 23 | - $rows[] = $row->getArrayCopy(); |
|
| 24 | - } |
|
| 15 | + /** |
|
| 16 | + * @return array |
|
| 17 | + */ |
|
| 18 | + public function getArrayCopy() |
|
| 19 | + { |
|
| 20 | + $rows = []; |
|
| 21 | + foreach ($this->data as $row) { |
|
| 22 | + /** @var DataSet $row */ |
|
| 23 | + $rows[] = $row->getArrayCopy(); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - return $rows; |
|
| 27 | - } |
|
| 26 | + return $rows; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @return array |
|
| 31 | - */ |
|
| 32 | - public function jsonSerialize() |
|
| 33 | - { |
|
| 34 | - $rows = []; |
|
| 35 | - foreach ($this->data as $row) { |
|
| 36 | - /** @var DataSet $row */ |
|
| 37 | - $rows[] = $row->jsonSerialize(); |
|
| 38 | - } |
|
| 29 | + /** |
|
| 30 | + * @return array |
|
| 31 | + */ |
|
| 32 | + public function jsonSerialize() |
|
| 33 | + { |
|
| 34 | + $rows = []; |
|
| 35 | + foreach ($this->data as $row) { |
|
| 36 | + /** @var DataSet $row */ |
|
| 37 | + $rows[] = $row->jsonSerialize(); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - return $rows; |
|
| 41 | - } |
|
| 40 | + return $rows; |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -11,26 +11,26 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | trait ArraySerializable |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Returns an array copy of the properties and their current values in this class |
|
| 16 | - * |
|
| 17 | - * @return array |
|
| 18 | - */ |
|
| 19 | - public function getArrayCopy() |
|
| 20 | - { |
|
| 21 | - $currentValues = array_map(function ($value) { |
|
| 22 | - if (is_object($value)) { |
|
| 23 | - if ($value instanceof ArraySerializableInterface) { |
|
| 24 | - return $value->getArrayCopy(); |
|
| 25 | - } |
|
| 26 | - } |
|
| 14 | + /** |
|
| 15 | + * Returns an array copy of the properties and their current values in this class |
|
| 16 | + * |
|
| 17 | + * @return array |
|
| 18 | + */ |
|
| 19 | + public function getArrayCopy() |
|
| 20 | + { |
|
| 21 | + $currentValues = array_map(function ($value) { |
|
| 22 | + if (is_object($value)) { |
|
| 23 | + if ($value instanceof ArraySerializableInterface) { |
|
| 24 | + return $value->getArrayCopy(); |
|
| 25 | + } |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - return $value; |
|
| 29 | - }, get_object_vars($this)); |
|
| 28 | + return $value; |
|
| 29 | + }, get_object_vars($this)); |
|
| 30 | 30 | |
| 31 | - // Filter out null values and return the remaining. |
|
| 32 | - return array_filter($currentValues, function ($value, $key) { |
|
| 33 | - return ! is_null($value) && $key !== 'owner'; |
|
| 34 | - }, ARRAY_FILTER_USE_BOTH); |
|
| 35 | - } |
|
| 31 | + // Filter out null values and return the remaining. |
|
| 32 | + return array_filter($currentValues, function ($value, $key) { |
|
| 33 | + return ! is_null($value) && $key !== 'owner'; |
|
| 34 | + }, ARRAY_FILTER_USE_BOTH); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -11,40 +11,40 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Json extends Renderer |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Render the necessary JSON for the chart to function in the frontend. |
|
| 16 | - * |
|
| 17 | - * @param int|false $flags |
|
| 18 | - * |
|
| 19 | - * @return string |
|
| 20 | - */ |
|
| 21 | - public function render($flags = null) |
|
| 22 | - { |
|
| 23 | - $config = [ |
|
| 24 | - 'type' => constant(get_class($this->chart) . "::TYPE"), |
|
| 25 | - 'data' => [], |
|
| 26 | - ]; |
|
| 27 | - |
|
| 28 | - $labels = $this->chart->labels()->jsonSerialize(); |
|
| 29 | - if ($labels) { |
|
| 30 | - $config['data']['labels'] = $labels; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - $dataSets = $this->chart->dataSets()->jsonSerialize(); |
|
| 34 | - if ($dataSets) { |
|
| 35 | - $config['data']['datasets'] = $dataSets; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - $options = $this->chart->options()->jsonSerialize(); |
|
| 39 | - if (! empty($options)) { |
|
| 40 | - $config['options'] = $options; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - $output = JsonHelper::encode($config, false, ['enableJsonExprFinder' => true]); |
|
| 44 | - if ($flags & Renderer::RENDER_PRETTY) { |
|
| 45 | - $output = JsonHelper::prettyPrint($output); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - return $output; |
|
| 49 | - } |
|
| 14 | + /** |
|
| 15 | + * Render the necessary JSON for the chart to function in the frontend. |
|
| 16 | + * |
|
| 17 | + * @param int|false $flags |
|
| 18 | + * |
|
| 19 | + * @return string |
|
| 20 | + */ |
|
| 21 | + public function render($flags = null) |
|
| 22 | + { |
|
| 23 | + $config = [ |
|
| 24 | + 'type' => constant(get_class($this->chart) . "::TYPE"), |
|
| 25 | + 'data' => [], |
|
| 26 | + ]; |
|
| 27 | + |
|
| 28 | + $labels = $this->chart->labels()->jsonSerialize(); |
|
| 29 | + if ($labels) { |
|
| 30 | + $config['data']['labels'] = $labels; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + $dataSets = $this->chart->dataSets()->jsonSerialize(); |
|
| 34 | + if ($dataSets) { |
|
| 35 | + $config['data']['datasets'] = $dataSets; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + $options = $this->chart->options()->jsonSerialize(); |
|
| 39 | + if (! empty($options)) { |
|
| 40 | + $config['options'] = $options; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + $output = JsonHelper::encode($config, false, ['enableJsonExprFinder' => true]); |
|
| 44 | + if ($flags & Renderer::RENDER_PRETTY) { |
|
| 45 | + $output = JsonHelper::prettyPrint($output); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + return $output; |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -9,28 +9,28 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | class JavaScript extends Renderer |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * Renders the necessary JavaScript for the chart to function in the frontend. |
|
| 14 | - * |
|
| 15 | - * @param int|null $flags |
|
| 16 | - * |
|
| 17 | - * @return string |
|
| 18 | - */ |
|
| 19 | - public function render($flags = null) |
|
| 20 | - { |
|
| 21 | - $script = []; |
|
| 12 | + /** |
|
| 13 | + * Renders the necessary JavaScript for the chart to function in the frontend. |
|
| 14 | + * |
|
| 15 | + * @param int|null $flags |
|
| 16 | + * |
|
| 17 | + * @return string |
|
| 18 | + */ |
|
| 19 | + public function render($flags = null) |
|
| 20 | + { |
|
| 21 | + $script = []; |
|
| 22 | 22 | |
| 23 | - // First, setup the canvas context |
|
| 24 | - $script[] = "var ctx = document.getElementById( \"{$this->chart->getId()}\" ).getContext( \"2d\" );"; |
|
| 23 | + // First, setup the canvas context |
|
| 24 | + $script[] = "var ctx = document.getElementById( \"{$this->chart->getId()}\" ).getContext( \"2d\" );"; |
|
| 25 | 25 | |
| 26 | - // Now, setup the chart instance |
|
| 27 | - $jsonRenderer = new Json($this->chart); |
|
| 28 | - $json = $jsonRenderer->render($flags); |
|
| 29 | - $script[] = "var chart = new Chart( ctx, {$json} );"; |
|
| 30 | - $scriptString = implode("\n", $script); |
|
| 26 | + // Now, setup the chart instance |
|
| 27 | + $jsonRenderer = new Json($this->chart); |
|
| 28 | + $json = $jsonRenderer->render($flags); |
|
| 29 | + $script[] = "var chart = new Chart( ctx, {$json} );"; |
|
| 30 | + $scriptString = implode("\n", $script); |
|
| 31 | 31 | |
| 32 | - // Return the script |
|
| 33 | - return <<<JS |
|
| 32 | + // Return the script |
|
| 33 | + return <<<JS |
|
| 34 | 34 | window.onload=(function(oldLoad){return function(){ |
| 35 | 35 | if (oldLoad) { |
| 36 | 36 | oldLoad(); |
@@ -45,6 +45,6 @@ discard block |
||
| 45 | 45 | window.chartInstances['{$this->chart->getId()}'] = chart; |
| 46 | 46 | }})(window.onload); |
| 47 | 47 | JS |
| 48 | - ; |
|
| 49 | - } |
|
| 48 | + ; |
|
| 49 | + } |
|
| 50 | 50 | } |