wip
This commit is contained in:
1 parent
c9114b5e65
commit
640328c1ca
3 files changed
+115
-33
No files matched your search
@@ -51,7 +51,7 @@ class ChartEventPerf extends ChartWidget
|
|||||||
tooltip: {
|
tooltip: {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: (context) => {
|
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]];
|
return [context.dataset.label+' '+context.dataset.data[0]];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -59,7 +59,12 @@ class ChartEventPerfMoAv extends ChartWidget
|
|||||||
tooltip: {
|
tooltip: {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: (context) => {
|
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]];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class LoadPerformance
|
|||||||
|
|
||||||
$home_matches = [];
|
$home_matches = [];
|
||||||
$away_matches = [];
|
$away_matches = [];
|
||||||
|
$league_matches = [];
|
||||||
$date_home = [];
|
$date_home = [];
|
||||||
$date_away = [];
|
$date_away = [];
|
||||||
$events_home = [];
|
$events_home = [];
|
||||||
@@ -45,6 +46,7 @@ class LoadPerformance
|
|||||||
$results_away = [];
|
$results_away = [];
|
||||||
$labels = [];
|
$labels = [];
|
||||||
foreach ($res as $val) {
|
foreach ($res as $val) {
|
||||||
|
$league_matches[] = $val->match_id;
|
||||||
|
|
||||||
if ($val->home_id == $home_id or $val->away_id == $home_id) {
|
if ($val->home_id == $home_id or $val->away_id == $home_id) {
|
||||||
$labels[] = round($val->starttime->diffInDays(Carbon::now()));
|
$labels[] = round($val->starttime->diffInDays(Carbon::now()));
|
||||||
@@ -69,10 +71,14 @@ class LoadPerformance
|
|||||||
$aways = self::filterMatches($res, $away_matches);
|
$aways = self::filterMatches($res, $away_matches);
|
||||||
|
|
||||||
self::shortenEnding($labels, $homes, $aways);
|
self::shortenEnding($labels, $homes, $aways);
|
||||||
|
|
||||||
$home_av = self::makeAv($homes);
|
$home_av = self::makeAv($homes);
|
||||||
$away_av = self::makeAv($aways);
|
$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 = [
|
$data = [
|
||||||
'datasets' => [
|
'datasets' => [
|
||||||
[
|
[
|
||||||
@@ -88,7 +94,7 @@ class LoadPerformance
|
|||||||
'pointStyle' => $hasdots,
|
'pointStyle' => $hasdots,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'label' => 'Average All',
|
'label' => 'Average Team',
|
||||||
'playing_date' => $date_home,
|
'playing_date' => $date_home,
|
||||||
'results_per_event' => $results_home,
|
'results_per_event' => $results_home,
|
||||||
'events' => $events_home,
|
'events' => $events_home,
|
||||||
@@ -108,8 +114,8 @@ class LoadPerformance
|
|||||||
'data' => $homes['def'] ?? [],
|
'data' => $homes['def'] ?? [],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#c10007',
|
'borderColor' => '#ff6900',
|
||||||
'backgroundColor' => '#c10007',
|
'backgroundColor' => '#ff6900',
|
||||||
'fill' => false,
|
'fill' => false,
|
||||||
'pointStyle' => $hasdots,
|
'pointStyle' => $hasdots,
|
||||||
'hidden' => true,
|
'hidden' => true,
|
||||||
@@ -122,8 +128,8 @@ class LoadPerformance
|
|||||||
'data' => $home_av['def'],
|
'data' => $home_av['def'],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#c10007',
|
'borderColor' => '#ff6900',
|
||||||
'backgroundColor' => '#c10007',
|
'backgroundColor' => '#ff6900',
|
||||||
'pointStyle' => false,
|
'pointStyle' => false,
|
||||||
'hidden' => true,
|
'hidden' => true,
|
||||||
'borderDash' => [5, 5],
|
'borderDash' => [5, 5],
|
||||||
@@ -136,8 +142,8 @@ class LoadPerformance
|
|||||||
'data' => $homes['att'] ?? [],
|
'data' => $homes['att'] ?? [],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#c10007',
|
'borderColor' => '#ff6900',
|
||||||
'backgroundColor' => '#c10007',
|
'backgroundColor' => '#ff6900',
|
||||||
'fill' => false,
|
'fill' => false,
|
||||||
'pointStyle' => $hasdots,
|
'pointStyle' => $hasdots,
|
||||||
'hidden' => true,
|
'hidden' => true,
|
||||||
@@ -150,8 +156,8 @@ class LoadPerformance
|
|||||||
'data' => $home_av['att'] ?? [],
|
'data' => $home_av['att'] ?? [],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#c10007',
|
'borderColor' => '#ff6900',
|
||||||
'backgroundColor' => '#c10007',
|
'backgroundColor' => '#ff6900',
|
||||||
'fill' => false,
|
'fill' => false,
|
||||||
'pointStyle' => false,
|
'pointStyle' => false,
|
||||||
'hidden' => true,
|
'hidden' => true,
|
||||||
@@ -165,8 +171,8 @@ class LoadPerformance
|
|||||||
'data' => $homes['mid'] ?? [],
|
'data' => $homes['mid'] ?? [],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#c10007',
|
'borderColor' => '#ff6900',
|
||||||
'backgroundColor' => '#c10007',
|
'backgroundColor' => '#ff6900',
|
||||||
'fill' => false,
|
'fill' => false,
|
||||||
'pointStyle' => $hasdots,
|
'pointStyle' => $hasdots,
|
||||||
'hidden' => true,
|
'hidden' => true,
|
||||||
@@ -179,8 +185,8 @@ class LoadPerformance
|
|||||||
'data' => $home_av['mid'] ?? [],
|
'data' => $home_av['mid'] ?? [],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#c10007',
|
'borderColor' => '#ff6900',
|
||||||
'backgroundColor' => '#c10007',
|
'backgroundColor' => '#ff6900',
|
||||||
'fill' => false,
|
'fill' => false,
|
||||||
'pointStyle' => false,
|
'pointStyle' => false,
|
||||||
'borderDash' => [5, 5],
|
'borderDash' => [5, 5],
|
||||||
@@ -194,22 +200,22 @@ class LoadPerformance
|
|||||||
'data' => $aways['all'] ?? [],
|
'data' => $aways['all'] ?? [],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#fdc700',
|
'borderColor' => '#00c950',
|
||||||
'backgroundColor' => '#fdc700',
|
'backgroundColor' => '#00c950',
|
||||||
'fill' => false,
|
'fill' => false,
|
||||||
'pointStyle' => $hasdots,
|
'pointStyle' => $hasdots,
|
||||||
'hidden' => true,
|
'hidden' => true,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'label' => 'Average All',
|
'label' => 'Average Team',
|
||||||
'playing_date' => $date_away,
|
'playing_date' => $date_away,
|
||||||
'results_per_event' => $results_away,
|
'results_per_event' => $results_away,
|
||||||
'events' => $events_away,
|
'events' => $events_away,
|
||||||
'data' => $away_av['all'] ?? [],
|
'data' => $away_av['all'] ?? [],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#fdc700',
|
'borderColor' => '#00c950',
|
||||||
'backgroundColor' => '#fdc700',
|
'backgroundColor' => '#00c950',
|
||||||
'fill' => false,
|
'fill' => false,
|
||||||
'pointStyle' => false,
|
'pointStyle' => false,
|
||||||
'borderDash' => [5, 5],
|
'borderDash' => [5, 5],
|
||||||
@@ -223,8 +229,8 @@ class LoadPerformance
|
|||||||
'data' => $aways['def'] ?? [],
|
'data' => $aways['def'] ?? [],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#d08700',
|
'borderColor' => '#009966',
|
||||||
'backgroundColor' => '#d08700',
|
'backgroundColor' => '#009966',
|
||||||
'fill' => false,
|
'fill' => false,
|
||||||
'pointStyle' => $hasdots,
|
'pointStyle' => $hasdots,
|
||||||
'hidden' => true,
|
'hidden' => true,
|
||||||
@@ -237,8 +243,8 @@ class LoadPerformance
|
|||||||
'data' => $away_av['def'] ?? [],
|
'data' => $away_av['def'] ?? [],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#d08700',
|
'borderColor' => '#009966',
|
||||||
'backgroundColor' => '#d08700',
|
'backgroundColor' => '#009966',
|
||||||
'fill' => false,
|
'fill' => false,
|
||||||
'pointStyle' => false,
|
'pointStyle' => false,
|
||||||
'borderDash' => [5, 5],
|
'borderDash' => [5, 5],
|
||||||
@@ -252,8 +258,8 @@ class LoadPerformance
|
|||||||
'data' => $aways['att'] ?? [],
|
'data' => $aways['att'] ?? [],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#d08700',
|
'borderColor' => '#009966',
|
||||||
'backgroundColor' => '#d08700',
|
'backgroundColor' => '#009966',
|
||||||
'fill' => false,
|
'fill' => false,
|
||||||
'pointStyle' => $hasdots,
|
'pointStyle' => $hasdots,
|
||||||
'hidden' => true,
|
'hidden' => true,
|
||||||
@@ -266,8 +272,8 @@ class LoadPerformance
|
|||||||
'data' => $away_av['att'] ?? [],
|
'data' => $away_av['att'] ?? [],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#d08700',
|
'borderColor' => '#009966',
|
||||||
'backgroundColor' => '#d08700',
|
'backgroundColor' => '#009966',
|
||||||
'fill' => false,
|
'fill' => false,
|
||||||
'pointStyle' => false,
|
'pointStyle' => false,
|
||||||
'borderDash' => [5, 5],
|
'borderDash' => [5, 5],
|
||||||
@@ -281,8 +287,8 @@ class LoadPerformance
|
|||||||
'data' => $aways['mid'] ?? [],
|
'data' => $aways['mid'] ?? [],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#d08700',
|
'borderColor' => '#009966',
|
||||||
'backgroundColor' => '#d08700',
|
'backgroundColor' => '#009966',
|
||||||
'fill' => false,
|
'fill' => false,
|
||||||
'pointStyle' => $hasdots,
|
'pointStyle' => $hasdots,
|
||||||
'hidden' => true,
|
'hidden' => true,
|
||||||
@@ -295,13 +301,69 @@ class LoadPerformance
|
|||||||
'data' => $away_av['mid'] ?? [],
|
'data' => $away_av['mid'] ?? [],
|
||||||
'spanGaps' => true,
|
'spanGaps' => true,
|
||||||
'tension' => 0.5,
|
'tension' => 0.5,
|
||||||
'borderColor' => '#d08700',
|
'borderColor' => '#009966',
|
||||||
'backgroundColor' => '#d08700',
|
'backgroundColor' => '#009966',
|
||||||
'fill' => false,
|
'fill' => false,
|
||||||
'pointStyle' => false,
|
'pointStyle' => false,
|
||||||
'borderDash' => [5, 5],
|
'borderDash' => [5, 5],
|
||||||
'hidden' => true,
|
'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,
|
'labels' => $labels,
|
||||||
];
|
];
|
||||||
@@ -432,4 +494,19 @@ class LoadPerformance
|
|||||||
|
|
||||||
return $ret;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user