F
Filament9mo ago
Arko

$columnSpan on StatOverviewWidget

I'm trying to get 4 stats per row, but changing the $columnSpan doesn't seem to do anything. For example:
class KpiStats extends StatsOverviewWidget
{
protected int | string | array $columnSpan = 1;

protected function getStats(): array
{
return [
Stat::make(__('Stat 1'),'€0,00'),
Stat::make(__('Stat 2'),'€0,00'),
Stat::make(__('Stat 3'),'€0,00'),
Stat::make(__('Stat 4'),'€0,00'),
Stat::make(__('Stat 5'),'€0,00'),
Stat::make(__('Stat 6'),'€0,00'),
Stat::make(__('Stat 7'),'€0,00'),
Stat::make(__('Stat 8'),'€0,00'),
];
}
}
class KpiStats extends StatsOverviewWidget
{
protected int | string | array $columnSpan = 1;

protected function getStats(): array
{
return [
Stat::make(__('Stat 1'),'€0,00'),
Stat::make(__('Stat 2'),'€0,00'),
Stat::make(__('Stat 3'),'€0,00'),
Stat::make(__('Stat 4'),'€0,00'),
Stat::make(__('Stat 5'),'€0,00'),
Stat::make(__('Stat 6'),'€0,00'),
Stat::make(__('Stat 7'),'€0,00'),
Stat::make(__('Stat 8'),'€0,00'),
];
}
}
21 Replies
Dan Harrin
Dan Harrin9mo ago
columnspan is about how wide the entire widget is not how many columns it has are you looking for $columns maybe?
Arko
Arko9mo ago
Doesn't seem to have a $columns property, but this works:
protected function getColumns(): int
{
return 4;
}
protected function getColumns(): int
{
return 4;
}
Thanks
Dan Harrin
Dan Harrin9mo ago
ah ok makes sense cause the number of columns is dynamic in the default implementation check parent::getColumns() if you wanna look
Arko
Arko9mo ago
Is there also a native way to get two charts in 1 row? Will do thanks
Dan Harrin
Dan Harrin9mo ago
yeah? by default? $columnSpan = 1 if your dashboard has 2 cols
Arko
Arko9mo ago
On a custom page I mean, sorry
Dan Harrin
Dan Harrin9mo ago
getHeaderWidgetsColumns() returns 2 so it should put them in 2 cols
Arko
Arko9mo ago
hmm ok gotcha thanks love whats on the agenda today
toeknee
toeknee9mo ago
you
Dan Harrin
Dan Harrin9mo ago
client work, then family visiting this weekend :) hbu
Arko
Arko9mo ago
working at client today, darts match tonight then weekend prepping for my trip to murica next week
Dan Harrin
Dan Harrin9mo ago
enjoy!
toeknee
toeknee9mo ago
Enjoy both of you!
Dan Harrin
Dan Harrin9mo ago
thanks
Arko
Arko9mo ago
what are ur plans (besides me)
toeknee
toeknee9mo ago
I've got the girlfriend round for netflix and chill Followed by a 5k run Lunch 10K walk Some work Then Take the girlfriend out on the motorbike and have a hike up the mountain and a coffee Follow by a nice lunch, then cooking a roast tea for some friends
Arko
Arko9mo ago
that sounds mostly exhausting best of luck brother
toeknee
toeknee9mo ago
ahahaha! It's completely fun and chill to me 😄
Arko
Arko9mo ago
have fun then 😄
toeknee
toeknee9mo ago
Absolutely