From b4379efb82735410bba148791e7f09abd34acd8e Mon Sep 17 00:00:00 2001 From: salam Date: Sat, 23 May 2026 12:40:14 +0200 Subject: [PATCH] wip --- .../Supervisors/Tables/SupervisorsTable.php | 2 +- .../Tables/StatistikoDetailsTable.php | 2 +- .../Tables/StatistikoEventsTable.php | 2 +- .../Tables/StatistikoPlayersTable.php | 2 +- app/Filament/Pages/Statistic.php | 2 + .../Resources/Events/Tables/EventsTable.php | 2 +- .../Widgets/ChartMovingAverageEvent.php | 21 ++++++ app/Filament/Widgets/ChartPunctualEvent.php | 69 +++++++++++++++++++ app/Filament/Widgets/Data/LoadEvents.php | 21 +++--- 9 files changed, 110 insertions(+), 13 deletions(-) diff --git a/app/Filament/Clusters/Grapper/Resources/Supervisors/Tables/SupervisorsTable.php b/app/Filament/Clusters/Grapper/Resources/Supervisors/Tables/SupervisorsTable.php index 86b62b98..06ae8754 100644 --- a/app/Filament/Clusters/Grapper/Resources/Supervisors/Tables/SupervisorsTable.php +++ b/app/Filament/Clusters/Grapper/Resources/Supervisors/Tables/SupervisorsTable.php @@ -31,7 +31,7 @@ class SupervisorsTable return $table ->striped() ->recordAction(null) - ->poll('10s') + ->poll('15sec') ->columns([ Split::make([ TextColumn::make('id')->badge()->alignCenter(), diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoDetails/Tables/StatistikoDetailsTable.php b/app/Filament/Clusters/StaticData/Resources/StatistikoDetails/Tables/StatistikoDetailsTable.php index adb2ac8d..3f81a5de 100644 --- a/app/Filament/Clusters/StaticData/Resources/StatistikoDetails/Tables/StatistikoDetailsTable.php +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoDetails/Tables/StatistikoDetailsTable.php @@ -13,7 +13,7 @@ class StatistikoDetailsTable public static function configure(Table $table): Table { return $table - ->poll('10sec') + ->poll('15sec') ->striped() ->defaultPaginationPageOption(8) ->paginationPageOptions([8, 16, 24, 36]) diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Tables/StatistikoEventsTable.php b/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Tables/StatistikoEventsTable.php index 8e85a734..3454f905 100644 --- a/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Tables/StatistikoEventsTable.php +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Tables/StatistikoEventsTable.php @@ -16,7 +16,7 @@ class StatistikoEventsTable public static function configure(Table $table): Table { return $table - ->poll('10sec') + ->poll('15sec') ->striped() ->columns([ IconColumn::make('sport_id') diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Tables/StatistikoPlayersTable.php b/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Tables/StatistikoPlayersTable.php index 6e0eafe9..bdae9da4 100644 --- a/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Tables/StatistikoPlayersTable.php +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Tables/StatistikoPlayersTable.php @@ -13,7 +13,7 @@ class StatistikoPlayersTable public static function configure(Table $table): Table { return $table - ->poll() + // ->poll() ->columns([ TextColumn::make('match_id')->searchable(), TextColumn::make('details.name') diff --git a/app/Filament/Pages/Statistic.php b/app/Filament/Pages/Statistic.php index b206eccb..7e68100c 100644 --- a/app/Filament/Pages/Statistic.php +++ b/app/Filament/Pages/Statistic.php @@ -30,6 +30,8 @@ class Statistic extends BaseDashboard protected static string|BackedEnum|null $navigationIcon = 'phosphor-chart-line-up'; + protected ?string $pollingInterval = null; + protected static ?string $title = 'Statistic'; protected int|string|array $columnSpan = [ diff --git a/app/Filament/Resources/Events/Tables/EventsTable.php b/app/Filament/Resources/Events/Tables/EventsTable.php index 0d871581..98e76cdf 100644 --- a/app/Filament/Resources/Events/Tables/EventsTable.php +++ b/app/Filament/Resources/Events/Tables/EventsTable.php @@ -61,7 +61,7 @@ class EventsTable return $table ->striped() - ->poll('20s') + ->poll('15sec') ->deferLoading() ->defaultPaginationPageOption(5) ->extremePaginationLinks() diff --git a/app/Filament/Widgets/ChartMovingAverageEvent.php b/app/Filament/Widgets/ChartMovingAverageEvent.php index 82b66267..936616db 100644 --- a/app/Filament/Widgets/ChartMovingAverageEvent.php +++ b/app/Filament/Widgets/ChartMovingAverageEvent.php @@ -5,6 +5,7 @@ namespace App\Filament\Widgets; use App\Filament\Widgets\Data\HelperMoveingAverage; use App\Filament\Widgets\Data\HelperStatisticType; use App\Filament\Widgets\Data\LoadEvents; +use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; use Filament\Widgets\Concerns\InteractsWithPageFilters; @@ -21,6 +22,26 @@ class ChartMovingAverageEvent extends ChartWidget 'legend' => [ 'display' => false, ], + 'tooltip' => [ + 'callbacks' => [ + 'label' => RawJs::make(<<<'JS' + function(context) { + let label = context.dataset.label || ''; + + if (label) { + label += ': '; + } + if (context.parsed.y !== null) { + label += new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(context.parsed.y); + } + return label; + } + JS), + ], + ], + ], + 'interaction' => [ + 'intersect' => false, ], ]; diff --git a/app/Filament/Widgets/ChartPunctualEvent.php b/app/Filament/Widgets/ChartPunctualEvent.php index ac886f65..40736e5e 100644 --- a/app/Filament/Widgets/ChartPunctualEvent.php +++ b/app/Filament/Widgets/ChartPunctualEvent.php @@ -4,6 +4,7 @@ namespace App\Filament\Widgets; use App\Filament\Widgets\Data\HelperStatisticType; use App\Filament\Widgets\Data\LoadEvents; +// use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; use Filament\Widgets\Concerns\InteractsWithPageFilters; @@ -21,6 +22,9 @@ class ChartPunctualEvent extends ChartWidget 'display' => false, ], ], + 'interaction' => [ + 'intersect' => false, + ], ]; public function getDescription(): ?string @@ -41,4 +45,69 @@ class ChartPunctualEvent extends ChartWidget { return 'line'; } + + // protected function getOptions(): RawJs|array + // { + // return RawJs::make(<<<'JS' + // { + // plugins: { + // legend: { + // display: false + // }, + // datalabels: { + // backgroundColor: function(context) { + // return context.active ? context.dataset.backgroundColor : 'white'; + // }, + // borderColor: function(context) { + // return context.dataset.backgroundColor; + // }, + // borderRadius: function(context) { + // return context.active ? 0 : 32; + // }, + // borderWidth: 3, + // color: function(context) { + // return context.active ? 'white' : context.dataset.backgroundColor; + // }, + // font: { + // weight: 'bold' + // }, + // formatter: function(value, context) { + // value = Math.round(value * 100) / 100; + // return context.active + // ? context.dataset.label + '\n' + value + '%' + // : Math.round(value); + // }, + // offset: 8, + // padding: 5, + // textAlign: 'center' + // } + // }, + // // Core options + // aspectRatio: 5 / 3, + // layout: { + // padding: { + // bottom: 16, + // right: 40, + // left: 8, + // top: 40 + // } + // }, + // hover: { + // mode: 'index', + // intersect: false + // }, + // elements: { + // line: { + // fill: false, + // tension: 0.4 + // } + // }, + // scales: { + // y: { + // stacked: true + // } + // } + // } + // JS); + // } } diff --git a/app/Filament/Widgets/Data/LoadEvents.php b/app/Filament/Widgets/Data/LoadEvents.php index a03f07a4..0f4e4393 100644 --- a/app/Filament/Widgets/Data/LoadEvents.php +++ b/app/Filament/Widgets/Data/LoadEvents.php @@ -31,14 +31,17 @@ class LoadEvents $statistic_type = $filter['statistic_type'] ?? 0; + $team_position = $filter['team_position']; + if (! $league_id) { return []; } if (! $team_id) { return []; } - - $team_position = $filter['team_position']; + if (! $statistic_type) { + return []; + } /** * STATTISTIC DATA @@ -60,7 +63,7 @@ class LoadEvents })->when($end, function ($query) use ($end) { return $query->where('starttime', '<=', $end); }) - ->orderBy('starttime') + ->orderBy('starttime', 'ASC') ->get(); // dd($res); @@ -71,12 +74,10 @@ class LoadEvents $datasets = []; $labels = []; - - if (! $statistic_type || $statistic_type == 'none') { - $statistic_type = 'gls'; - } + $labels_since = []; foreach ($res as $value) { + $labels[] = $value['starttime']->format('d.M.y'); if ($team_position == 'home') { @@ -189,11 +190,15 @@ class LoadEvents $data = [ 'datasets' => [ [ - 'label' => ucfirst($team_position), + 'label' => HelperStatisticType::get($filter), 'data' => $datasets, 'fill' => true, 'tension' => 0.5, 'borderColor' => '#36A2EB', + 'datalabels' => [ + 'align' => 'start', + 'anchor' => 'start', + ], ], ], 'labels' => $labels,