Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 18035

How to use chartjs plugins in laravel filament V3 widgets?

$
0
0

I am trying to use the chartjs plugin chartjs-plugin-datalabels in my doughnut chart widget. I have done the steps mentioned in the this filament documentation

I am using as in the below code for the widget. I am able to see the chart but I am not seeing the data labels. I am not sure how to use the plugin in side my code.

class PaymentStatusChart extends ChartWidget{    protected static ?string $heading = 'Payment Status';    protected function getData(): array    {        $studentFees = StudentFee::groupBy('status')        ->selectRaw('status, count(*) as count')        ->get();        return ['datasets' => [            ['label' => 'Payment Status','data' => $studentFees->pluck('count'),'datalabels' => ['anchor'=> 'center','backgroundColor' => null,'borderWidth'=> 0               ],'backgroundColor' => ['rgb(255, 99, 132)','rgb(54, 162, 235)','rgb(255, 205, 86)'                ],'borderColor' => '#9BD0F5',            ],        ],'labels' => $studentFees->pluck('status'),      ];    }    protected function getOptions(): array    {      return ['plugins' => ['legend'     => ['display' => true,],'datalabels' => ['display' => true,'borderColor'=> 'white','borderRadius'=> 25,'borderWidth'=> 2,'color'=> 'white',            ],        ],'scales' => ['x' => ['display' => false,],'y' => ['display' => false,]        ]      ];    }    protected function getType(): string    {        return 'doughnut';    }}

Viewing all articles
Browse latest Browse all 18035

Trending Articles