From 6aae6061d1497fd11972aff0dd48592c7be24c5f Mon Sep 17 00:00:00 2001 From: Peter Thomson Date: Thu, 30 May 2024 12:57:49 +1200 Subject: [PATCH] Fix livewire component and null on optionsRaw(). --- src/Builder.php | 4 ++-- src/resources/views/chart-template-livewire.blade.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Builder.php b/src/Builder.php index c2d248b..f0a9f0e 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -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([ diff --git a/src/resources/views/chart-template-livewire.blade.php b/src/resources/views/chart-template-livewire.blade.php index ba11711..09dbcdb 100644 --- a/src/resources/views/chart-template-livewire.blade.php +++ b/src/resources/views/chart-template-livewire.blade.php @@ -102,7 +102,7 @@ let { labels, datasets } = dataset return new Chart(el, { - type: 'line', + type: {!! $type !!}, data: { labels: labels, datasets: datasets,