Skip to content

Commit

Permalink
Fix livewire component and null on optionsRaw().
Browse files Browse the repository at this point in the history
Peter Thomson committed May 30, 2024
1 parent 4a87ed9 commit 6aae606
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Builder.php
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ public function options(array $options)
* @param string|array $optionsRaw
* @return \self
*/
public function optionsRaw($optionsRaw)
public function optionsRaw(string|array $optionsRaw)
{
if (is_array($optionsRaw)) {
$this->set('optionsRaw', json_encode($optionsRaw, true));
@@ -163,7 +163,7 @@ public function render()
$view = $inLivewire ? 'chart-template::chart-template-livewire' : Config::getChartViewName(); // Should probably add another config setting for the Livewire version

$optionsRaw = $chart['optionsRaw'] ?? null;
$optionsSimple = isset($chart['options']) ? json_encode($chart['options']) : null;
$optionsSimple = $chart['options'] ? json_encode($chart['options']) : null;
$options = $optionsRaw ? $optionsRaw : $optionsSimple;

return view($view)->with([
2 changes: 1 addition & 1 deletion src/resources/views/chart-template-livewire.blade.php
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@
let { labels, datasets } = dataset
return new Chart(el, {
type: 'line',
type: {!! $type !!},
data: {
labels: labels,
datasets: datasets,

0 comments on commit 6aae606

Please sign in to comment.