diff --git a/app/Filament/Widgets/ChartMovingAverageEvent.php b/app/Filament/Widgets/ChartMovingAverageEvent.php index ce565f32..9bcf61b0 100644 --- a/app/Filament/Widgets/ChartMovingAverageEvent.php +++ b/app/Filament/Widgets/ChartMovingAverageEvent.php @@ -17,7 +17,7 @@ class ChartMovingAverageEvent extends ChartWidget protected ?array $options = [ 'plugins' => [ 'legend' => [ - 'display' => false, + 'display' => true, ], ], 'interaction' => [ diff --git a/app/Filament/Widgets/ChartPunctualEvent.php b/app/Filament/Widgets/ChartPunctualEvent.php index 10c3cc41..accd1ae5 100644 --- a/app/Filament/Widgets/ChartPunctualEvent.php +++ b/app/Filament/Widgets/ChartPunctualEvent.php @@ -16,7 +16,7 @@ class ChartPunctualEvent extends ChartWidget protected ?array $options = [ 'plugins' => [ 'legend' => [ - 'display' => false, + 'display' => true, ], ], 'interaction' => [ diff --git a/app/Filament/Widgets/Data/HelperMoveingAverage.php b/app/Filament/Widgets/Data/HelperMoveingAverage.php index 83481ec3..3dc2adc9 100644 --- a/app/Filament/Widgets/Data/HelperMoveingAverage.php +++ b/app/Filament/Widgets/Data/HelperMoveingAverage.php @@ -7,20 +7,23 @@ class HelperMoveingAverage public static function get(&$data) { - $arr = $data['datasets'][0]['data']; + // $arr = $data['datasets'][0]['data'];# $data['labels'] = array_slice($data['labels'], 2); - $new = []; - $last = count($arr); - foreach ($arr as $key => $value) { - if ($key == 1 && $last > 2) { - $new[] = round(($arr[0] + $value + $arr[2]) / 3, 1); - } elseif ($key > 1 && $key < $last - 1) { - $new[] = round(($arr[$key - 1] + $value + $arr[$key + 1]) / 3, 1); + $datasets = $data['datasets']; + foreach ($datasets as $k => $dataset) { + $arr = $dataset['data']; + $new = []; + $last = count($arr); + foreach ($arr as $key => $value) { + if ($key == 1 && $last > 2) { + $new[] = round(($arr[0] + $value + $arr[2]) / 3, 1); + } elseif ($key > 1 && $key < $last - 1) { + $new[] = round(($arr[$key - 1] + $value + $arr[$key + 1]) / 3, 1); + } } + $data['datasets'][$k]['data'] = $new; } - $data['datasets'][0]['borderColor'] = '#00a63e'; - $data['datasets'][0]['data'] = $new; } } diff --git a/app/Filament/Widgets/Data/LoadEvents.php b/app/Filament/Widgets/Data/LoadEvents.php index ded4189f..1c5bf804 100644 --- a/app/Filament/Widgets/Data/LoadEvents.php +++ b/app/Filament/Widgets/Data/LoadEvents.php @@ -101,7 +101,8 @@ class LoadEvents return []; } - $datasets = []; + $dataset_home = []; + $dataset_away = []; $labels = []; $labels_since = []; $results = ['w' => 0, 'd' => 0, 'l' => 0]; @@ -125,25 +126,32 @@ class LoadEvents switch ($statistic_type) { case 'gls': - $val = (int) $value['gls_h']; + $val_home = (int) $value['gls_h']; + $val_away = (int) $value['gls_a']; break; case 'crn': - $val = (int) $value['crn_h']; + $val_home = (int) $value['crn_h']; + $val_away = (int) $value['crn_a']; break; case 'fls': - $val = (int) $value['fls_h']; + $val_home = (int) $value['fls_h']; + $val_away = (int) $value['fls_a']; break; case 'ofs': - $val = (int) $value['ofs_h']; + $val_home = (int) $value['ofs_h']; + $val_away = (int) $value['ofs_a']; break; case 'crd': - $val = (int) $value['crd_h']; + $val_home = (int) $value['crd_h']; + $val_away = (int) $value['crd_a']; break; case 'snt': - $val = (int) $value['snt_h']; + $val_home = (int) $value['snt_h']; + $val_away = (int) $value['snt_a']; break; case 'tsh': - $val = (int) $value['tsh_h']; + $val_home = (int) $value['tsh_h']; + $val_away = (int) $value['tsh_a']; break; } } elseif ($team_position == 'away') { @@ -162,25 +170,32 @@ class LoadEvents switch ($statistic_type) { case 'gls': - $val = (int) $value['gls_a']; + $val_home = (int) $value['gls_a']; + $val_away = (int) $value['gls_h']; break; case 'crn': - $val = (int) $value['crn_a']; + $val_home = (int) $value['crn_a']; + $val_away = (int) $value['crn_h']; break; case 'fls': - $val = (int) $value['fls_a']; + $val_home = (int) $value['fls_a']; + $val_away = (int) $value['fls_h']; break; case 'ofs': - $val = (int) $value['ofs_a']; + $val_home = (int) $value['ofs_a']; + $val_away = (int) $value['ofs_h']; break; case 'crd': - $val = (int) $value['crd_a']; + $val_home = (int) $value['crd_a']; + $val_away = (int) $value['crds_h']; break; case 'snt': - $val = (int) $value['snt_a']; + $val_home = (int) $value['snt_a']; + $val_away = (int) $value['snt_h']; break; case 'tsh': - $val = (int) $value['tsh_a']; + $val_home = (int) $value['tsh_a']; + $val_away = (int) $value['tsh_h']; break; } } else { @@ -207,69 +222,92 @@ class LoadEvents switch ($statistic_type) { case 'gls': if ($team_id == $value['home_id']) { - $val = (int) $value['gls_h']; + $val_home = (int) $value['gls_h']; + $val_away = (int) $value['gls_a']; } else { - $val = (int) $value['gls_a']; + $val_home = (int) $value['gls_a']; + $val_away = (int) $value['gls_h']; } break; case 'crn': if ($team_id == $value['home_id']) { - $val = (int) $value['crn_h']; + $val_home = (int) $value['crn_h']; + $val_away = (int) $value['crn_a']; } else { - $val = (int) $value['crn_a']; + $val_home = (int) $value['crn_a']; + $val_away = (int) $value['crn_h']; } break; case 'fls': if ($team_id == $value['home_id']) { - $val = (int) $value['fls_h']; + $val_home = (int) $value['fls_h']; + $val_away = (int) $value['fls_a']; } else { - $val = (int) $value['fls_a']; + $val_home = (int) $value['fls_a']; + $val_away = (int) $value['fls_h']; } break; case 'ofs': if ($team_id == $value['home_id']) { - $val = (int) $value['ofs_h']; + $val_home = (int) $value['ofs_h']; + $val_away = (int) $value['ofs_a']; } else { - $val = (int) $value['ofs_a']; + $val_home = (int) $value['ofs_a']; + $val_away = (int) $value['ofs_h']; } break; case 'crd': if ($team_id == $value['home_id']) { - $val = (int) $value['crd_h']; + $val_home = (int) $value['crd_h']; + $val_away = (int) $value['crd_a']; } else { - $val = (int) $value['crd_a']; + $val_home = (int) $value['crd_a']; + $val_away = (int) $value['crd_h']; } break; case 'snt': if ($team_id == $value['home_id']) { - $val = (int) $value['snt_h']; + $val_home = (int) $value['snt_h']; + $val_away = (int) $value['snt_a']; } else { - $val = (int) $value['snt_a']; + $val_home = (int) $value['snt_a']; + $val_away = (int) $value['snt_h']; } break; case 'tsh': if ($team_id == $value['home_id']) { - $val = (int) $value['tsh_h']; + $val_home = (int) $value['tsh_h']; + $val_away = (int) $value['tsh_a']; } else { - $val = (int) $value['tsh_a']; + $val_home = (int) $value['tsh_a']; + $val_away = (int) $value['tsh_h']; } break; } } - if (isset($val)) { - $datasets[] = $val; + if (isset($val_home) && isset($val_away)) { + $dataset_home[] = $val_home; + $dataset_away[] = $val_away; } } $data = [ 'datasets' => [ [ - 'label' => HelperStatisticType::get($filter), - 'data' => $datasets, - 'fill' => true, + 'label' => 'Home', + 'data' => $dataset_home, + 'fill' => false, 'tension' => 0.5, 'borderColor' => '#36A2EB', ], + [ + // 'label' => 'Away '.HelperStatisticType::get($filter), + 'label' => 'Away', + 'data' => $dataset_away, + 'fill' => false, + 'tension' => 0.5, + 'borderColor' => '#7ccf00', + ], ], 'labels' => $labels, 'description' => $description ?? '',