Skip to content

Commit

Permalink
optionsRaw supports a string or a php array
Browse files Browse the repository at this point in the history
  • Loading branch information
fxcosta committed Aug 13, 2017
1 parent b2b1560 commit 7083c08
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 7083c08

Please sign in to comment.