50 lines
997 B
PHP
50 lines
997 B
PHP
<?php
|
|
|
|
namespace App\Filament\Widgets;
|
|
|
|
use App\Actions\Statistics\LoadEvents;
|
|
use App\Actions\Statistics\MoveingAverage;
|
|
use App\Actions\Statistics\StatisticType;
|
|
use Filament\Widgets\ChartWidget;
|
|
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
|
|
|
class MovingAverageChart extends ChartWidget
|
|
{
|
|
use InteractsWithPageFilters;
|
|
|
|
protected ?string $pollingInterval = null;
|
|
|
|
public ?string $header;
|
|
|
|
protected ?array $options = [
|
|
'plugins' => [
|
|
'legend' => [
|
|
'display' => false,
|
|
],
|
|
],
|
|
];
|
|
|
|
public function getDescription(): ?string
|
|
{
|
|
return 'Moving Average';
|
|
}
|
|
|
|
protected function getData(): array
|
|
{
|
|
$this->heading = StatisticType::get($this->filters);
|
|
|
|
$data = LoadEvents::load($this->filters);
|
|
|
|
if ($data) {
|
|
MoveingAverage::get($data);
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
protected function getType(): string
|
|
{
|
|
return 'line';
|
|
}
|
|
}
|