diff --git a/app/Livewire/StatisticEventChart.php b/app/Livewire/StatisticEventChart.php
index 04e1b8da..5310fb0a 100644
--- a/app/Livewire/StatisticEventChart.php
+++ b/app/Livewire/StatisticEventChart.php
@@ -4,61 +4,77 @@ namespace App\Livewire;
use App\Models\Event;
use App\Models\StatistikoEvent;
+use Filament\Forms\Components\Select;
+use Filament\Schemas\Schema;
use Filament\Widgets\ChartWidget;
+use Filament\Widgets\ChartWidget\Concerns\HasFiltersSchema;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\HtmlString;
class StatisticEventChart extends ChartWidget
{
+ use HasFiltersSchema;
+
public Event $record;
- public ?string $filter = 'gls';
+ // protected bool $hasDeferredFilters = true;
- protected bool $hasDeferredFilters = true;
+ public ?string $filter = 'gls';
protected ?string $pollingInterval = null;
public function getHeading(): string|Htmlable|null
{
- $str = '
';
- $str .= '
'.$this->record->country->name.' '.$this->record->group->name.'
';
- if ($this->record->home->betsapi_image_id) {
- $str .= '

';
- }
- $str .= '
'.$this->record->home->name.'
';
- $str .= '
vs
';
- $str .= '
'.$this->record->away->name.'
';
- if ($this->record->away->betsapi_image_id) {
- $str .= '

';
- }
- $str .= '
';
+ // $str = '';
+ // $str .= '
'.$this->record->country->name.' '.$this->record->group->name.'
';
+ // if ($this->record->home->betsapi_image_id) {
+ // $str .= '

';
+ // }
+ // $str .= '
'.$this->record->home->name.'
';
+ // $str .= '
vs
';
+ // $str .= '
'.$this->record->away->name.'
';
+ // if ($this->record->away->betsapi_image_id) {
+ // $str .= '

';
+ // }
+ // $str .= '
';
- return new HtmlString($str);
+ return new HtmlString($this->record->country->name.' '.$this->record->group->name);
}
- protected function getFilters(): ?array
+ public function filtersSchema(Schema $schema): Schema
{
- return [
- 'gls' => 'Goals',
- 'crn' => 'Corner',
- 'fls' => 'Committed Fouls',
- 'ofs' => 'Offsides',
- 'crd' => 'Cards',
- 'snt' => 'Shots on target',
- 'tsh' => 'TotalShots',
- ];
+ return $schema->schema([
+ Select::make('data_mode')
+ ->default('gls')
+ ->options([
+ 'gls' => 'Goals',
+ 'crn' => 'Corner',
+ 'fls' => 'Committed Fouls',
+ 'ofs' => 'Offsides',
+ 'crd' => 'Cards',
+ 'snt' => 'Shots on target',
+ 'tsh' => 'TotalShots',
+ ]),
+ Select::make('claculation_mode')
+ ->default('punctual')
+ ->options([
+ 'punctual' => 'Punctual',
+ 'average' => 'Moving average',
+ ]),
+ ]);
}
protected function getData(): array
{
- $activeFilter = $this->filter;
+ $data_mode = $this->filters['data_mode'] ?? null;
+ $claculation_mode = $this->filters['claculation_mode'] ?? null;
$res = StatistikoEvent::where('league_id', $this->record['competition_group_id'])
->where('home_id', $this->record['home_id'])
- ->where('away_id', $this->record['away_id'])
+ // ->where('away_id', $this->record['away_id'])
->get();
- switch ($activeFilter) {
+ switch ($data_mode) {
case 'crn':
$h = 'crn_h';
$a = 'crn_a';
@@ -130,9 +146,17 @@ class StatisticEventChart extends ChartWidget
],
],
],
+ 'plugins' => [
+ 'legend' => [
+ 'display' => true,
+ 'position' => 'top', // Set position to 'top'
+ ],
+ ],
];
}
+ // ], layout: FiltersLayout::AboveContent)
+
protected function getType(): string
{
return 'line';