From 640328c1caca206dfbdf9bc5ad2dab24adf9ecda Mon Sep 17 00:00:00 2001 From: salam Date: Tue, 16 Jun 2026 15:44:12 +0200 Subject: [PATCH] wip --- app/Filament/Widgets/ChartEventPerf.php | 2 +- app/Filament/Widgets/ChartEventPerfMoAv.php | 7 +- app/Filament/Widgets/Data/LoadPerformance.php | 139 ++++++++++++++---- 3 files changed, 115 insertions(+), 33 deletions(-) diff --git a/app/Filament/Widgets/ChartEventPerf.php b/app/Filament/Widgets/ChartEventPerf.php index 1f48462c..58bf22af 100644 --- a/app/Filament/Widgets/ChartEventPerf.php +++ b/app/Filament/Widgets/ChartEventPerf.php @@ -51,7 +51,7 @@ class ChartEventPerf extends ChartWidget tooltip: { callbacks: { label: (context) => { - if(context.dataset.label == 'Average All' || context.dataset.label == 'Average Attak'|| context.dataset.label == 'Average Denfence'|| context.dataset.label == 'Average Midfield'){ + if(context.dataset.label == 'Average Team' || context.dataset.label == 'Average League' || context.dataset.label == 'Average Attak'|| context.dataset.label == 'Average Defence'|| context.dataset.label == 'Average Midfield'){ return [context.dataset.label+' '+context.dataset.data[0]]; } else { diff --git a/app/Filament/Widgets/ChartEventPerfMoAv.php b/app/Filament/Widgets/ChartEventPerfMoAv.php index 43faf42e..b8e0322b 100644 --- a/app/Filament/Widgets/ChartEventPerfMoAv.php +++ b/app/Filament/Widgets/ChartEventPerfMoAv.php @@ -59,7 +59,12 @@ class ChartEventPerfMoAv extends ChartWidget tooltip: { callbacks: { label: (context) => { - return [' '+context.parsed.y, ' '+context.dataset.playing_date[context.dataIndex], ' '+context.dataset.events[context.dataIndex], ' '+context.dataset.results_per_event[context.dataIndex]]; + if(context.dataset.label == 'Average Team' || context.dataset.label == 'Average Attak'|| context.dataset.label == 'Average Denfence'|| context.dataset.label == 'Average Midfield'){ + return [context.dataset.label+' '+context.dataset.data[0]]; + } + else { + return [' '+context.parsed.y, ' '+context.dataset.playing_date[context.dataIndex], ' '+context.dataset.events[context.dataIndex], ' '+context.dataset.results_per_event[context.dataIndex]]; + } }, } } diff --git a/app/Filament/Widgets/Data/LoadPerformance.php b/app/Filament/Widgets/Data/LoadPerformance.php index 5852ea6c..a43d1b0e 100644 --- a/app/Filament/Widgets/Data/LoadPerformance.php +++ b/app/Filament/Widgets/Data/LoadPerformance.php @@ -37,6 +37,7 @@ class LoadPerformance $home_matches = []; $away_matches = []; + $league_matches = []; $date_home = []; $date_away = []; $events_home = []; @@ -45,6 +46,7 @@ class LoadPerformance $results_away = []; $labels = []; foreach ($res as $val) { + $league_matches[] = $val->match_id; if ($val->home_id == $home_id or $val->away_id == $home_id) { $labels[] = round($val->starttime->diffInDays(Carbon::now())); @@ -69,10 +71,14 @@ class LoadPerformance $aways = self::filterMatches($res, $away_matches); self::shortenEnding($labels, $homes, $aways); - $home_av = self::makeAv($homes); $away_av = self::makeAv($aways); + + $res = StatistikoPlayer::whereIn('match_id', $league_matches)->select('match_id', 'minutes_played', 'playerrating_value', 'player_position')->get(); + $league = self::filterMatches($res, $league_matches); + $league_av = self::leagueAv($league, count($homes['all'])); + $data = [ 'datasets' => [ [ @@ -88,7 +94,7 @@ class LoadPerformance 'pointStyle' => $hasdots, ], [ - 'label' => 'Average All', + 'label' => 'Average Team', 'playing_date' => $date_home, 'results_per_event' => $results_home, 'events' => $events_home, @@ -108,8 +114,8 @@ class LoadPerformance 'data' => $homes['def'] ?? [], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#c10007', - 'backgroundColor' => '#c10007', + 'borderColor' => '#ff6900', + 'backgroundColor' => '#ff6900', 'fill' => false, 'pointStyle' => $hasdots, 'hidden' => true, @@ -122,8 +128,8 @@ class LoadPerformance 'data' => $home_av['def'], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#c10007', - 'backgroundColor' => '#c10007', + 'borderColor' => '#ff6900', + 'backgroundColor' => '#ff6900', 'pointStyle' => false, 'hidden' => true, 'borderDash' => [5, 5], @@ -136,8 +142,8 @@ class LoadPerformance 'data' => $homes['att'] ?? [], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#c10007', - 'backgroundColor' => '#c10007', + 'borderColor' => '#ff6900', + 'backgroundColor' => '#ff6900', 'fill' => false, 'pointStyle' => $hasdots, 'hidden' => true, @@ -150,8 +156,8 @@ class LoadPerformance 'data' => $home_av['att'] ?? [], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#c10007', - 'backgroundColor' => '#c10007', + 'borderColor' => '#ff6900', + 'backgroundColor' => '#ff6900', 'fill' => false, 'pointStyle' => false, 'hidden' => true, @@ -165,8 +171,8 @@ class LoadPerformance 'data' => $homes['mid'] ?? [], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#c10007', - 'backgroundColor' => '#c10007', + 'borderColor' => '#ff6900', + 'backgroundColor' => '#ff6900', 'fill' => false, 'pointStyle' => $hasdots, 'hidden' => true, @@ -179,8 +185,8 @@ class LoadPerformance 'data' => $home_av['mid'] ?? [], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#c10007', - 'backgroundColor' => '#c10007', + 'borderColor' => '#ff6900', + 'backgroundColor' => '#ff6900', 'fill' => false, 'pointStyle' => false, 'borderDash' => [5, 5], @@ -194,22 +200,22 @@ class LoadPerformance 'data' => $aways['all'] ?? [], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#fdc700', - 'backgroundColor' => '#fdc700', + 'borderColor' => '#00c950', + 'backgroundColor' => '#00c950', 'fill' => false, 'pointStyle' => $hasdots, 'hidden' => true, ], [ - 'label' => 'Average All', + 'label' => 'Average Team', 'playing_date' => $date_away, 'results_per_event' => $results_away, 'events' => $events_away, 'data' => $away_av['all'] ?? [], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#fdc700', - 'backgroundColor' => '#fdc700', + 'borderColor' => '#00c950', + 'backgroundColor' => '#00c950', 'fill' => false, 'pointStyle' => false, 'borderDash' => [5, 5], @@ -223,8 +229,8 @@ class LoadPerformance 'data' => $aways['def'] ?? [], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#d08700', - 'backgroundColor' => '#d08700', + 'borderColor' => '#009966', + 'backgroundColor' => '#009966', 'fill' => false, 'pointStyle' => $hasdots, 'hidden' => true, @@ -237,8 +243,8 @@ class LoadPerformance 'data' => $away_av['def'] ?? [], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#d08700', - 'backgroundColor' => '#d08700', + 'borderColor' => '#009966', + 'backgroundColor' => '#009966', 'fill' => false, 'pointStyle' => false, 'borderDash' => [5, 5], @@ -252,8 +258,8 @@ class LoadPerformance 'data' => $aways['att'] ?? [], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#d08700', - 'backgroundColor' => '#d08700', + 'borderColor' => '#009966', + 'backgroundColor' => '#009966', 'fill' => false, 'pointStyle' => $hasdots, 'hidden' => true, @@ -266,8 +272,8 @@ class LoadPerformance 'data' => $away_av['att'] ?? [], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#d08700', - 'backgroundColor' => '#d08700', + 'borderColor' => '#009966', + 'backgroundColor' => '#009966', 'fill' => false, 'pointStyle' => false, 'borderDash' => [5, 5], @@ -281,8 +287,8 @@ class LoadPerformance 'data' => $aways['mid'] ?? [], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#d08700', - 'backgroundColor' => '#d08700', + 'borderColor' => '#009966', + 'backgroundColor' => '#009966', 'fill' => false, 'pointStyle' => $hasdots, 'hidden' => true, @@ -295,13 +301,69 @@ class LoadPerformance 'data' => $away_av['mid'] ?? [], 'spanGaps' => true, 'tension' => 0.5, - 'borderColor' => '#d08700', - 'backgroundColor' => '#d08700', + 'borderColor' => '#009966', + 'backgroundColor' => '#009966', 'fill' => false, 'pointStyle' => false, 'borderDash' => [5, 5], 'hidden' => true, ], + [ + 'label' => 'Average League', + 'playing_date' => $date_home, + 'results_per_event' => $results_home, + 'events' => $events_home, + 'data' => $league_av['all'], + 'spanGaps' => true, + 'tension' => 0.5, + 'borderColor' => '#00a6f4', + 'backgroundColor' => '#00a6f4', + 'pointStyle' => false, + 'borderDash' => [5, 5], + 'hidden' => true, + ], + [ + 'label' => 'Average Defence', + 'playing_date' => $date_home, + 'results_per_event' => $results_home, + 'events' => $events_home, + 'data' => $league_av['def'], + 'spanGaps' => true, + 'tension' => 0.5, + 'borderColor' => '#155dfc', + 'backgroundColor' => '#155dfc', + 'pointStyle' => false, + 'borderDash' => [5, 5], + 'hidden' => true, + ], + [ + 'label' => 'Average Attak', + 'playing_date' => $date_home, + 'results_per_event' => $results_home, + 'events' => $events_home, + 'data' => $league_av['att'], + 'spanGaps' => true, + 'tension' => 0.5, + 'borderColor' => '#155dfc', + 'backgroundColor' => '#155dfc', + 'pointStyle' => false, + 'borderDash' => [5, 5], + 'hidden' => true, + ], + [ + 'label' => 'Average Midfield', + 'playing_date' => $date_home, + 'results_per_event' => $results_home, + 'events' => $events_home, + 'data' => $league_av['mid'], + 'spanGaps' => true, + 'tension' => 0.5, + 'borderColor' => '#155dfc', + 'backgroundColor' => '#155dfc', + 'pointStyle' => false, + 'borderDash' => [5, 5], + 'hidden' => true, + ], ], 'labels' => $labels, ]; @@ -432,4 +494,19 @@ class LoadPerformance return $ret; } + + public static function leagueAv(array &$arr, $len) + { + $all = array_sum($arr['all']) / count($arr['all']); + $def = array_sum($arr['def']) / count($arr['def']); + $mid = array_sum($arr['mid']) / count($arr['mid']); + $att = array_sum($arr['att']) / count($arr['att']); + $ret = []; + $ret['all'] = array_fill(0, $len, round($all, 2)); + $ret['def'] = array_fill(0, $len, round($def, 2)); + $ret['mid'] = array_fill(0, $len, round($mid, 2)); + $ret['att'] = array_fill(0, $len, round($att, 2)); + + return $ret; + } }