livewire-charts
livewire-charts copied to clipboard
Uncaught TypeError: Cannot read properties of undefined (reading 'get')
Describe the bug Uncaught TypeError: Cannot read properties of undefined (reading 'get') at Proxy.drawChart (app.js:3:472873) at app.js:3:472785
To Reproduce Steps to reproduce the behavior:
-
'$columnChartModel = (new ColumnChartModel()) ->setTitle('Expenses by Type') ->addColumn('Food', 100, '#f6ad55') ->addColumn('Shopping', 200, '#fc8181') ->addColumn('Travel', 300, '#90cdf4') ;'
-
'<livewire:livewire-column-chart :column-chart-model="$columnChartModel" />'
-
'Uncaught TypeError: Cannot read properties of undefined (reading 'get') at Proxy.drawChart (app.js:3:472873) at app.js:3:472785'
Solution Ideas thinking
This is probably because Livewire is not properly initialized or not installed, follow these instructions:
Requirements
This package requires the following packages/libraries to work:
-
Laravel Livewire v2
(https://laravel-livewire.com/) -
Alpine Js
(https://github.com/alpinejs/alpine) -
Apex Charts
(https://apexcharts.com/)
Please follow each package/library instructions on how to set them properly in your project.
Next, include the @livewireChartsScripts
directive next to your other app scripts
<livewire:scripts />
@livewireChartsScripts
I get the same error. Even Livewire works well on other pages.
I tried with local apexcharts:
<script src="{{asset('js/apexcharts.js')}}"></script> @livewireScripts @livewireChartsScripts
but error didn't disappear.
This was my issue an hour ago. I just found out that I did not add window.Alpine = Alpine
in my bundle after importing the Alpine module.
I hope this helps.