Chart widget with chart.js plugins
I'm trying to add datalabels plugin for Chart.js. I'm following this steps from the docs: https://filamentphp.com/docs/3.x/widgets/charts#using-custom-chartjs-plugins with no luck. I'm getting an Alpine error. I attached ss from widget and resources/js/filament-chart-js-plugins.js.
I rebuilt assets, cleared browser cache, nothing changes. But if I comment all the code from filament-chart-js-plugins.js the error disappear




9 Replies
You also need x-ignore on the ax-load element.
I think
Actually you’re confusing ax-load with x-load
I'm not using custom view, I'm just using a chart widget by default
Should I change that to custom widget (livewire)?
Ah. Sorry, looked custom.
Did you miss the step about registering it with FilamentAsset?
Nope, I've already registered 😦

Its a fresh laravel/filament installation btw
That is an unusual error though. I saw something similar the other day with x-sort where it complained about x not being defined without explicitly defining it as x-sort=“” since the browser was setting the attribute itself as x-sort=“x-sort” wonder if something changed recently in alpine.
@awcodes Hi, I installed the chartjs-plugin-annotation plugin using the NPM command. When the chart widget is loaded I'm getting this error. I followed the steps indicated in the Filament Docs and registered the plugins file in the AppServiceProvider. Any suggestions?

For anybody going through this same issue while trying to use chartjs-datalabels-plugin.
This is a issue with chartjs-datalabels-plugin itself, and only happen for doughnut and pie charts. I don't think anybody there will fix it, the Repo is pretty much idle.
I found an alternative that 'kinda' works:
chart.js-plugin-labels-dv
After installing the package through npm, the .js file will be like this: