This commit is contained in:
salam committed 2026-06-16 12:46:34 +02:00
1 parent a8e3c62185
commit f26057119c
1 file changed
+135 -2
+135 -2
View File
@@ -21,8 +21,6 @@ class LoadPerformance
$match_id = (int) $filter['match_id'] ?? 0;
$tm_player_id = (int) $filter['tm_player_id'] ?? 0;
if (! $league_id) {
return [];
}
@@ -72,6 +70,9 @@ class LoadPerformance
self::shortenEnding($labels, $homes, $aways);
$home_av = self::makeAv($homes);
$away_av = self::makeAv($aways);
$data = [
'datasets' => [
[
@@ -86,6 +87,19 @@ class LoadPerformance
'backgroundColor' => '#fb2c36',
'pointStyle' => $hasdots,
],
[
'label' => 'Average All',
'playing_date' => $date_home,
'results_per_event' => $results_home,
'events' => $events_home,
'data' => $home_av['all'],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#fb2c36',
'backgroundColor' => '#fb2c36',
'pointStyle' => false,
'borderDash' => [5, 5],
],
[
'label' => 'Defence',
'playing_date' => $date_home,
@@ -100,6 +114,20 @@ class LoadPerformance
'pointStyle' => $hasdots,
'hidden' => true,
],
[
'label' => 'Average Defence',
'playing_date' => $date_home,
'results_per_event' => $results_home,
'events' => $events_home,
'data' => $home_av['def'],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#c10007',
'backgroundColor' => '#c10007',
'pointStyle' => false,
'hidden' => true,
'borderDash' => [5, 5],
],
[
'label' => 'Attak',
'playing_date' => $date_home,
@@ -114,6 +142,21 @@ class LoadPerformance
'pointStyle' => $hasdots,
'hidden' => true,
],
[
'label' => 'Average Attak',
'playing_date' => $date_home,
'results_per_event' => $results_home,
'events' => $events_home,
'data' => $home_av['att'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#c10007',
'backgroundColor' => '#c10007',
'fill' => false,
'pointStyle' => false,
'hidden' => true,
'borderDash' => [5, 5],
],
[
'label' => 'Midfield',
'playing_date' => $date_home,
@@ -128,6 +171,21 @@ class LoadPerformance
'pointStyle' => $hasdots,
'hidden' => true,
],
[
'label' => 'Average Midfield',
'playing_date' => $date_home,
'results_per_event' => $results_home,
'events' => $events_home,
'data' => $home_av['mid'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#c10007',
'backgroundColor' => '#c10007',
'fill' => false,
'pointStyle' => false,
'borderDash' => [5, 5],
'hidden' => true,
],
[
'label' => $match->away->name,
'playing_date' => $date_away,
@@ -142,6 +200,21 @@ class LoadPerformance
'pointStyle' => $hasdots,
'hidden' => true,
],
[
'label' => 'Average All',
'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',
'fill' => false,
'pointStyle' => false,
'borderDash' => [5, 5],
'hidden' => true,
],
[
'label' => 'Defence',
'playing_date' => $date_away,
@@ -156,6 +229,21 @@ class LoadPerformance
'pointStyle' => $hasdots,
'hidden' => true,
],
[
'label' => 'Average Defence',
'playing_date' => $date_away,
'results_per_event' => $results_away,
'events' => $events_away,
'data' => $away_av['def'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#d08700',
'backgroundColor' => '#d08700',
'fill' => false,
'pointStyle' => false,
'borderDash' => [5, 5],
'hidden' => true,
],
[
'label' => 'Attak',
'playing_date' => $date_away,
@@ -170,6 +258,21 @@ class LoadPerformance
'pointStyle' => $hasdots,
'hidden' => true,
],
[
'label' => 'Average Attak',
'playing_date' => $date_away,
'results_per_event' => $results_away,
'events' => $events_away,
'data' => $away_av['att'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#d08700',
'backgroundColor' => '#d08700',
'fill' => false,
'pointStyle' => false,
'borderDash' => [5, 5],
'hidden' => true,
],
[
'label' => 'Midfield',
'playing_date' => $date_away,
@@ -184,6 +287,21 @@ class LoadPerformance
'pointStyle' => $hasdots,
'hidden' => true,
],
[
'label' => 'Average Midfield',
'playing_date' => $date_away,
'results_per_event' => $results_away,
'events' => $events_away,
'data' => $away_av['mid'] ?? [],
'spanGaps' => true,
'tension' => 0.5,
'borderColor' => '#d08700',
'backgroundColor' => '#d08700',
'fill' => false,
'pointStyle' => false,
'borderDash' => [5, 5],
'hidden' => true,
],
],
'labels' => $labels,
];
@@ -299,4 +417,19 @@ class LoadPerformance
// $labels = array_slice($labels, 0, $keeps);
$labels = range(1, $keeps);
}
public static function makeAv(array &$arr)
{
$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, count($arr['all']), round($all, 2));
$ret['def'] = array_fill(0, count($arr['def']), round($def, 2));
$ret['mid'] = array_fill(0, count($arr['mid']), round($mid, 2));
$ret['att'] = array_fill(0, count($arr['att']), round($att, 2));
return $ret;
}
}