diff --git a/app/Filament/Pages/Statistic.php b/app/Filament/Pages/Statistic.php index 766db7e5..d1616243 100644 --- a/app/Filament/Pages/Statistic.php +++ b/app/Filament/Pages/Statistic.php @@ -7,9 +7,11 @@ use App\Actions\LoadStatisticFixturesMatchOptions; use App\Filament\Widgets\ChartEvent; use App\Filament\Widgets\ChartEventMoAv; use App\Filament\Widgets\ChartEventPerf; +use App\Filament\Widgets\ChartEventPerfMoAv; use App\Filament\Widgets\ChartPlayer; use App\Filament\Widgets\ChartPlayerMoAv; use App\Filament\Widgets\ChartPlayerPerf; +use App\Filament\Widgets\ChartPlayerPerfMoAv; use App\Filament\Widgets\StatsMedianAverage; use App\Models\Element; use App\Models\StatisticFixtures; @@ -231,7 +233,7 @@ class Statistic extends BaseDashboard return [ 'default' => 1, 'md' => 2, - 'lg' => 3, + // 'lg' => 3, ]; } @@ -256,10 +258,12 @@ class Statistic extends BaseDashboard ChartEvent::make(), ChartEventMoAv::make(), ChartEventPerf::make(), + ChartEventPerfMoAv::make(), // Players ChartPlayer::make(), ChartPlayerMoAv::make(), ChartPlayerPerf::make(), + ChartPlayerPerfMoAv::make(), ]; } diff --git a/app/Filament/Widgets/ChartEventPerfMoAv.php b/app/Filament/Widgets/ChartEventPerfMoAv.php new file mode 100644 index 00000000..74f656e0 --- /dev/null +++ b/app/Filament/Widgets/ChartEventPerfMoAv.php @@ -0,0 +1,75 @@ +filters); + + if ($data) { + + HelperMoveingAveragePerformens::get($data); + } + + return $data; + } + + protected function getType(): string + { + return 'line'; + } + + protected function getOptions(): RawJs + { + return RawJs::make(<<<'JS' + { + interaction: { + intersect: false, + }, + // plugins: { + // 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]]; + // }, + // } + // } + // }, + scales: { + x: { + title: { + display: true, + text: 'Days since today' + } + }, + y: { + beginAtZero:false, + ticks: { + callback: function(value, index, ticks) { + return value % 1 === 0 ? value : ''; + } + } + }, + }, + } + JS); + } +} diff --git a/app/Filament/Widgets/ChartPlayerPerfMoAv.php b/app/Filament/Widgets/ChartPlayerPerfMoAv.php new file mode 100644 index 00000000..a97cbf04 --- /dev/null +++ b/app/Filament/Widgets/ChartPlayerPerfMoAv.php @@ -0,0 +1,31 @@ + $dataset) { + $arr = $dataset['data']; + + self::fillHoles($arr); + + $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; + } + } + + public static function fillHoles(array &$arr) + { + if (! $arr[0]) { + // get first value in array and copy it to start if start is null + $arr[0] = current(array_filter($arr)); + } + foreach ($arr as $key => $value) { + if ($value) { + $priv = $value; + } else { + $arr[$key] = $priv; + } + } + } +} diff --git a/app/Filament/Widgets/Data/LoadPerformance.php b/app/Filament/Widgets/Data/LoadPerformance.php index 23e03df9..85aee157 100644 --- a/app/Filament/Widgets/Data/LoadPerformance.php +++ b/app/Filament/Widgets/Data/LoadPerformance.php @@ -188,7 +188,7 @@ class LoadPerformance if ($value->player_position == 'M') { $result[$match_id]['mid']['sum_min'] += $value->minutes_played; $result[$match_id]['mid']['rating'] += $value->playerrating_value * $value->minutes_played; - } elseif ($value->player_position == 'A') { + } elseif ($value->player_position == 'F') { $result[$match_id]['att']['sum_min'] += $value->minutes_played; $result[$match_id]['att']['rating'] += $value->playerrating_value * $value->minutes_played; } elseif ($value->player_position == 'D') {