This commit is contained in:
salam committed 2026-05-29 16:38:15 +02:00
1 parent eea1a8de4e
commit eb8bf5f3f0
6 files changed
+282 -159

No files matched your search

+45 -27
View File
@@ -2,8 +2,8 @@
namespace App\Filament\Widgets;
use App\Filament\Widgets\Data\HelperStatisticType;
use App\Filament\Widgets\Data\LoadPlayer;
use Filament\Support\RawJs;
use Filament\Widgets\ChartWidget;
use Filament\Widgets\Concerns\InteractsWithPageFilters;
@@ -17,36 +17,14 @@ class ChartPlayer extends ChartWidget
protected ?string $heading = 'Player';
protected ?array $options = [
'plugins' => [
'legend' => [
'display' => false,
],
],
'interaction' => [
'intersect' => false,
],
'callbacks' => [
'label' => 'function(context) {
return " Count: " + context.raw;
}',
],
];
protected function getData(): array
{
if ($this->filters['statistic_type'] == 'crn') {
return [];
}
$this->description = HelperStatisticType::get($this->filters);
if (isset($data['description'])) {
$this->description .= $data['description'];
}
$data = LoadPlayer::load($this->filters);
if ($data) {
$this->description = $data['player_name'];
}
return $data;
}
@@ -54,4 +32,44 @@ class ChartPlayer extends ChartWidget
{
return 'line';
}
// , ' '+context.dataset.playing_date[context.dataIndex], ' '+context.dataset.events[context.dataIndex]
protected function getOptions(): RawJs
{
return RawJs::make(<<<'JS'
{
interaction: {
intersect: false,
},
plugins: {
tooltip: {
callbacks: {
afterLabel: (context) => {
let event = context.dataset.events[context.dataIndex] || '';
let date = context.dataset.dates[context.dataIndex] || '';
return event+' '+ date;
},
}
}
},
scales: {
x: {
title: {
display: true,
text: 'Days since today'
}
},
y: {
beginAtZero:true,
ticks: {
callback: function(value, index, ticks) {
return value % 1 === 0 ? value : '';
}
}
},
},
}
JS);
}
}