Multiple Dataset Chat Bar columns in widget and per month.

I'm trying to migrate my dashboard that i did with chart js on Filament , and i have this code ,
What i wanna do is this: having multiple dealers (Concesionarios) per month and the sum of some data for each month and each dealer
The mode is a View that already have a group by and order by date , also it will be nice if i can filter by date range, disable enable dealers

$datos = CantidadCanjesXConcesionario::all();
$concesionariosChart = $datos->groupBy('Concesionario');
$groupedFecha = $datos->groupBy('Fecha')->keys()->toArray();

$concesionariosChart = collect($concesionariosChart);
$groupedFecha = collect($groupedFecha);
$Chartdata = [
'datasets' => $concesionariosChart->map(function ($value, $key) use($groupedFecha) {
return [
'label' => $key,
'backgroundColor' => $this->ConcesionarioColors[$key] ?? [],
'data' => $groupedFecha->map(function ($fecha) use ($value) {
return $value->where('Fecha', $fecha)->pluck('Cantidad')->first() ?? 0;
})->toArray()
];
})->toArray()
];

return [
$Chartdata
];
Was this page helpful?