60 lines
1.4 KiB
PHP
60 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Widgets;
|
|
|
|
use App\Filament\Widgets\Data\LoadPlayerPerformance;
|
|
use Filament\Support\RawJs;
|
|
use Filament\Widgets\ChartWidget;
|
|
use Livewire\Attributes\Reactive;
|
|
|
|
class ChartPlayerPerfMoAv extends ChartWidget
|
|
{
|
|
#[Reactive]
|
|
public ?array $filters = [];
|
|
|
|
protected ?string $heading = 'Player';
|
|
|
|
protected ?string $description = 'Performance Moving Average';
|
|
|
|
protected ?string $pollingInterval = null;
|
|
|
|
protected bool $isCollapsible = true;
|
|
|
|
protected function getData(): array
|
|
{
|
|
return LoadPlayerPerformance::load($this->filters);
|
|
}
|
|
|
|
protected function getType(): string
|
|
{
|
|
return 'line';
|
|
}
|
|
|
|
protected function getOptions(): RawJs
|
|
{
|
|
return RawJs::make(<<<'JS'
|
|
{
|
|
interaction: {
|
|
intersect: false,
|
|
},
|
|
scales: {
|
|
x: {
|
|
title: {
|
|
display: true,
|
|
text: 'Days since today'
|
|
}
|
|
},
|
|
y: {
|
|
beginAtZero:true,
|
|
ticks: {
|
|
callback: function(value, index, ticks) {
|
|
return value % 1 === 0 ? value : '';
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}
|
|
JS);
|
|
}
|
|
}
|