ArielMejiaDev / larapex-charts

A Laravel wrapper for apex charts
https://larapex-charts.netlify.app/
MIT License
286 stars 82 forks source link

Charts not being displayed with custom layout #14

Closed Jean-Da-Rocha closed 3 years ago

Jean-Da-Rocha commented 3 years ago

I'm using Laravel 8 with a custom layout.

I want to display a chart in view called 'home.blade.php' which extends my layout.

When I extend this layout, the chart isn't being displayed but when I don't extend the layout, the chart is being displayed.

Did I miss something ? Is it a known issue ?

// home.blade.php
<x-layouts.app>
    {!! $chart->container() !!}

    <script src="{{ $chart->cdn() }}"></script>

    {{ $chart->script() }}
</x-layouts.app>

(With layout) image

(Without layout) image

ArielMejiaDev commented 3 years ago

You can extend the blade view, but remember that the data to build the chart needs to be added on every blade view, so here you can add the chart data on every view or add a view composer if the chart would be present in a lot of views.

Hope it helps.