I have noticed something with the "undefined variable $chart" error. It was caused when I moved the main layout file to the components folder. That is when I started to implement the Laravel's components feature.
I have created a similar file and placed it on the layouts folder and changed my view file to use the initial methods; @extends and @yield().
Hi, you are using the new Laravel components? in this case if you are using variables you need to add a class to add the component logic, look at "app/Views" folder, you can create a view composition class with the artisan command: "php artisan make:component yourcomponent", then it will add a file with a render function that calls directly the view then in the constructor add the $chart variable that you need maybe something like:
phpartisanmake:componentEarningsChart
go to app/Views/chart.php
<?phpnamespaceApp\View\Components;useIlluminate\View\Component;useArielMejiaDev\LarapexCharts\LarapexChart;classAlertextendsComponent{/**
* Chart instance.
*
*/public$chart;/**
* Create the component instance.
*
* @param $chart
* @return void
*/publicfunction__construct(LarapexChart$chart){$this->chart=(newLarapexChart)->setType('line')->setTitle('Earnings')->setXAxis(['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'])->setDataset([['name'=>'Earnings','data'=>[0,10000,15000,10000,20000,15000,25000,20000,30000,25000,40000]]]);}/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\View\View|string
*/publicfunctionrender(){returnview('components.alert');}}
Please let me know if this approach works, and congrats your Tall dashboard looks amazing, I am doing a secret open source project with similar aproach but I prefer VueJS
hi,, i'm using larapexchart in laravel but i keep on getting a error .. saying that Call to a member function container() on array.. can you help me please...
If you want to share the code I can give a look at the code, alternatively you can make a "dd()" to the chart variable before pass it to the view and check that its a LarapexChart object instance.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I have noticed something with the "undefined variable $chart" error. It was caused when I moved the main layout file to the components folder. That is when I started to implement the Laravel's components feature.
I have created a similar file and placed it on the layouts folder and changed my view file to use the initial methods; @extends and @yield().
Hi, you are using the new Laravel components? in this case if you are using variables you need to add a class to add the component logic, look at "app/Views" folder, you can create a view composition class with the artisan command: "php artisan make:component yourcomponent", then it will add a file with a render function that calls directly the view then in the constructor add the $chart variable that you need maybe something like:
go to app/Views/chart.php
Please let me know if this approach works, and congrats your Tall dashboard looks amazing, I am doing a secret open source project with similar aproach but I prefer VueJS
Thanks for your feedback. I will try out this approach and I'll let you know if it works. Also, I can't wait to see your project.
Thanks!
hi,, i'm using larapexchart in laravel but i keep on getting a error .. saying that Call to a member function container() on array.. can you help me please...
Hi there! thanks for using Larapex charts, here is a live sample with TailwindCSS: larapex-chart-example.herokuapp.com/
Here the controller where I built the charts: github.com/ArielMejiaDev/Larapex-C...
Here the view: github.com/ArielMejiaDev/Larapex-C...
If you want to share the code I can give a look at the code, alternatively you can make a "dd()" to the chart variable before pass it to the view and check that its a LarapexChart object instance.