How do you add plugins to chart widget? #689
-
I am using the Backpack Chart Widget which uses the chartjs by default. How do I configure my Chart Widget to use those plugins? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @A-Taqi , There is no built-in way for you to use those plugins. But you can create a custom Chart widget, based on ours. Here are some quick steps and pseudocode from the back of my head: Solution A. Create a new blade file (eg. @include('backpack.pro::widgets.chart')
@push('after_scripts')
<script>
// TODO: your custom code
</script>
@endpush Then you can use your custom chart widget, instead of the one provided by PRO: Widget::add([
'type' => 'custom-chart',
'wrapper' => ['class' => 'col-sm-12'],
// ...
]); Solution B. Just copy the blade file from the repo, to your I recommend solution A, because you'll also be getting any updates we push to that blade file. But if that's not possible, option B should be good enough too. Hope it helps! |
Beta Was this translation helpful? Give feedback.
Hi @A-Taqi ,
There is no built-in way for you to use those plugins. But you can create a custom Chart widget, based on ours. Here are some quick steps and pseudocode from the back of my head:
Solution A. Create a new blade file (eg.
resources/views/vendor/backpack/ui/widgets/custom-chart.blade.php
). Inside it, include our blade file, then at the end add a section to push any scripts or changes you want:Then you can use your custom chart widget, instead of the one provided by PRO: