This commit is contained in:
salam committed 2026-04-24 14:53:56 +02:00
1 parent e7973f6302
commit 8dba4bed04
1 file changed
+52 -28
+52 -28
View File
@@ -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 = '<div class="flex flex-row gap-4 justify-center bg-gray-300 font-thin">';
$str .= '<div>'.$this->record->country->name.' '.$this->record->group->name.'</div>';
if ($this->record->home->betsapi_image_id) {
$str .= ' <img src="https://assets.b365api.com/images/team/m/'.$this->record->home->betsapi_image_id.'.png" class="h-6">';
}
$str .= '<div>'.$this->record->home->name.'</div>';
$str .= '<div>vs</div>';
$str .= '<div>'.$this->record->away->name.'</div>';
if ($this->record->away->betsapi_image_id) {
$str .= ' <img src="https://assets.b365api.com/images/team/m/'.$this->record->away->betsapi_image_id.'.png" class="h-6">';
}
$str .= '</div>';
// $str = '<div class="flex flex-row gap-4 justify-center bg-gray-300 font-thin">';
// $str .= '<div>'.$this->record->country->name.' '.$this->record->group->name.'</div>';
// if ($this->record->home->betsapi_image_id) {
// $str .= ' <img src="https://assets.b365api.com/images/team/m/'.$this->record->home->betsapi_image_id.'.png" class="h-6">';
// }
// $str .= '<div>'.$this->record->home->name.'</div>';
// $str .= '<div>vs</div>';
// $str .= '<div>'.$this->record->away->name.'</div>';
// if ($this->record->away->betsapi_image_id) {
// $str .= ' <img src="https://assets.b365api.com/images/team/m/'.$this->record->away->betsapi_image_id.'.png" class="h-6">';
// }
// $str .= '</div>';
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';