Files
nuhodds_fi4/app/Filament/Widgets/MovingAverageChart.php
T
2026-04-29 19:00:46 +02:00

65 lines
1.6 KiB
PHP

<?php
namespace App\Filament\Widgets;
use App\Actions\Statistics\LoadEvents;
use App\Actions\Statistics\StatisticType;
use Filament\Notifications\Notification;
use Filament\Widgets\ChartWidget;
use Filament\Widgets\Concerns\InteractsWithPageFilters;
use Illuminate\Support\Facades\Log;
class MovingAverageChart extends ChartWidget
{
use InteractsWithPageFilters;
protected ?string $pollingInterval = null;
public ?string $header;
public function getDescription(): ?string
{
return 'Moving Average';
}
protected function getData(): array
{
$this->heading = StatisticType::get($this->filters);
if (! $this->filters['league_id']) {
return [];
}
if (! $this->filters['team_id']) {
// Notification::make()
// ->title('Team is missing')
// ->warning()
// ->send();
return [];
}
// Log::info($this->filters);
$tmp = LoadEvents::load($this->filters);
Log::info($tmp);
$data = [
'datasets' => [
[
'label' => 'test',
'data' => [0, 10, 5, 2, 21, 32, 45, 74, 65, 45, 77, 89],
'borderColor' => '#00c950',
'backgroundColor' => '#00c950',
],
],
'labels' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
];
return $data;
}
protected function getType(): string
{
return 'line';
}
}