diff --git a/README.md b/README.md index cb10973..21429c3 100755 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Since the current version allows it to add simple json string based options, it Using the method optionsRaw(string) its possible to add a the options in raw format: +Passing string format like a json ```php $chart->optionsRaw("{ legend: { @@ -74,6 +75,30 @@ Using the method optionsRaw(string) its possible to add a the options in raw for }"); ``` +Or, if your prefer, you can pass a php array format + +```php +$chart->optionsRaw([ + 'legend' => [ + 'display' => true, + 'labels' => [ + 'fontColor' => '#000' + ] + ], + 'scales' => [ + 'xAxes' => [ + [ + 'stacked' => true, + 'gridLines' => [ + 'display' => true + ] + ] + ] + ] +]); +``` + + # Examples 1 - Line Chart / Radar Chart: diff --git a/src/Builder.php b/src/Builder.php index ac98da8..e3f0382 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -125,11 +125,16 @@ public function options(array $options) /** * - * @param string $optionsRaw + * @param string|array $optionsRaw * @return \self */ - public function optionsRaw(string $optionsRaw) + public function optionsRaw($optionsRaw) { + if (is_array($optionsRaw)) { + $this->set('optionsRaw', json_encode($optionsRaw, true)); + return $this; + } + $this->set('optionsRaw', $optionsRaw); return $this; }