60 lines
1.4 KiB
PHP
60 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Widgets;
|
|
|
|
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 ChartPunctualEvent extends ChartWidget
|
|
{
|
|
use InteractsWithPageFilters;
|
|
|
|
protected ?string $pollingInterval = null;
|
|
|
|
protected function getData(): array
|
|
{
|
|
$this->heading = 'Events '.HelperStatisticType::get($this->filters);
|
|
|
|
$data = LoadEvents::load($this->filters);
|
|
|
|
if (isset($data['description'])) {
|
|
$this->description = 'Punctual '.$data['description'];
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
protected function getType(): string
|
|
{
|
|
return 'line';
|
|
}
|
|
|
|
protected function getOptions(): RawJs
|
|
{
|
|
return RawJs::make(<<<'JS'
|
|
{
|
|
interaction: {
|
|
intersect: false,
|
|
},
|
|
plugins: {
|
|
tooltip: {
|
|
callbacks: {
|
|
label: (context) => {
|
|
return [context.parsed.y, context.dataset.events[context.dataIndex]];
|
|
},
|
|
}
|
|
},
|
|
},
|
|
scales: {
|
|
y: {
|
|
beginAtZero:true,
|
|
},
|
|
},
|
|
}
|
|
JS);
|
|
}
|
|
}
|