wip
This commit is contained in:
1 parent
eea1a8de4e
commit
eb8bf5f3f0
6 files changed
+282
-159
No files matched your search
@@ -3,8 +3,8 @@
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Filament\Widgets\Data\HelperMoveingAverage;
|
||||
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;
|
||||
|
||||
@@ -18,33 +18,13 @@ class ChartPlayerMoAv extends ChartWidget
|
||||
|
||||
protected ?string $heading = 'Player';
|
||||
|
||||
protected ?array $options = [
|
||||
'plugins' => [
|
||||
'legend' => [
|
||||
'display' => false,
|
||||
],
|
||||
],
|
||||
'interaction' => [
|
||||
'intersect' => false,
|
||||
],
|
||||
'scales' => [
|
||||
'y' => [
|
||||
'beginAtZero' => true,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
if ($this->filters['statistic_type'] == 'crn') {
|
||||
return [];
|
||||
}
|
||||
|
||||
$this->description = ucfirst(HelperStatisticType::get($this->filters)).' Moving Average';
|
||||
|
||||
$data = LoadPlayer::load($this->filters);
|
||||
|
||||
if ($data) {
|
||||
$this->description = 'Moving Average '.$data['player_name'];
|
||||
|
||||
HelperMoveingAverage::get($data);
|
||||
}
|
||||
|
||||
@@ -55,4 +35,42 @@ class ChartPlayerMoAv extends ChartWidget
|
||||
{
|
||||
return 'line';
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user