82 lines
2.0 KiB
PHP
82 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Widgets;
|
|
|
|
use App\Filament\Widgets\Data\HelperMoveingAverage;
|
|
use App\Filament\Widgets\Data\HelperStatisticType;
|
|
use App\Filament\Widgets\Data\LoadEvents;
|
|
use Filament\Support\RawJs;
|
|
use Filament\Widgets\ChartWidget;
|
|
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
|
|
|
class ChartMovingAverageEvent extends ChartWidget
|
|
{
|
|
use InteractsWithPageFilters;
|
|
|
|
protected ?string $pollingInterval = null;
|
|
|
|
public ?string $header;
|
|
|
|
protected ?array $options = [
|
|
'plugins' => [
|
|
'legend' => [
|
|
'display' => false,
|
|
],
|
|
],
|
|
'interaction' => [
|
|
'intersect' => false,
|
|
],
|
|
];
|
|
|
|
public function getDescription(): ?string
|
|
{
|
|
return 'Events Moving Average';
|
|
}
|
|
|
|
protected function getData(): array
|
|
{
|
|
$this->heading = HelperStatisticType::get($this->filters);
|
|
|
|
$data = LoadEvents::load($this->filters);
|
|
|
|
if ($data) {
|
|
HelperMoveingAverage::get($data);
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
protected function getType(): string
|
|
{
|
|
return 'line';
|
|
}
|
|
|
|
// protected function getOptions(): array|RawJs|null
|
|
// {
|
|
// return [
|
|
// 'plugins' => [
|
|
// 'legend' => [
|
|
// 'display' => display,
|
|
// ],
|
|
// 'tooltip' => [
|
|
// 'callbacks' => [
|
|
// 'label' => RawJs::make(<<<'JS'
|
|
// function(context) {
|
|
// let label = context.dataset.label || '';
|
|
|
|
// if (label) {
|
|
// label += ': ';
|
|
// }
|
|
// return label;
|
|
// }
|
|
// JS),
|
|
// ],
|
|
// ],
|
|
// ],
|
|
// 'interaction' => [
|
|
// 'intersect' => false,
|
|
// ],
|
|
// ];
|
|
// }
|
|
}
|