This commit is contained in:
salam committed 2026-05-23 12:40:14 +02:00
1 parent fbaadcd248
commit b4379efb82
9 files changed
+110 -13

No files matched your search

@@ -31,7 +31,7 @@ class SupervisorsTable
return $table return $table
->striped() ->striped()
->recordAction(null) ->recordAction(null)
->poll('10s') ->poll('15sec')
->columns([ ->columns([
Split::make([ Split::make([
TextColumn::make('id')->badge()->alignCenter(), TextColumn::make('id')->badge()->alignCenter(),
@@ -13,7 +13,7 @@ class StatistikoDetailsTable
public static function configure(Table $table): Table public static function configure(Table $table): Table
{ {
return $table return $table
->poll('10sec') ->poll('15sec')
->striped() ->striped()
->defaultPaginationPageOption(8) ->defaultPaginationPageOption(8)
->paginationPageOptions([8, 16, 24, 36]) ->paginationPageOptions([8, 16, 24, 36])
@@ -16,7 +16,7 @@ class StatistikoEventsTable
public static function configure(Table $table): Table public static function configure(Table $table): Table
{ {
return $table return $table
->poll('10sec') ->poll('15sec')
->striped() ->striped()
->columns([ ->columns([
IconColumn::make('sport_id') IconColumn::make('sport_id')
@@ -13,7 +13,7 @@ class StatistikoPlayersTable
public static function configure(Table $table): Table public static function configure(Table $table): Table
{ {
return $table return $table
->poll() // ->poll()
->columns([ ->columns([
TextColumn::make('match_id')->searchable(), TextColumn::make('match_id')->searchable(),
TextColumn::make('details.name') TextColumn::make('details.name')
+2
View File
@@ -30,6 +30,8 @@ class Statistic extends BaseDashboard
protected static string|BackedEnum|null $navigationIcon = 'phosphor-chart-line-up'; protected static string|BackedEnum|null $navigationIcon = 'phosphor-chart-line-up';
protected ?string $pollingInterval = null;
protected static ?string $title = 'Statistic'; protected static ?string $title = 'Statistic';
protected int|string|array $columnSpan = [ protected int|string|array $columnSpan = [
@@ -61,7 +61,7 @@ class EventsTable
return $table return $table
->striped() ->striped()
->poll('20s') ->poll('15sec')
->deferLoading() ->deferLoading()
->defaultPaginationPageOption(5) ->defaultPaginationPageOption(5)
->extremePaginationLinks() ->extremePaginationLinks()
@@ -5,6 +5,7 @@ namespace App\Filament\Widgets;
use App\Filament\Widgets\Data\HelperMoveingAverage; use App\Filament\Widgets\Data\HelperMoveingAverage;
use App\Filament\Widgets\Data\HelperStatisticType; use App\Filament\Widgets\Data\HelperStatisticType;
use App\Filament\Widgets\Data\LoadEvents; use App\Filament\Widgets\Data\LoadEvents;
use Filament\Support\RawJs;
use Filament\Widgets\ChartWidget; use Filament\Widgets\ChartWidget;
use Filament\Widgets\Concerns\InteractsWithPageFilters; use Filament\Widgets\Concerns\InteractsWithPageFilters;
@@ -21,6 +22,26 @@ class ChartMovingAverageEvent extends ChartWidget
'legend' => [ 'legend' => [
'display' => false, 'display' => false,
], ],
'tooltip' => [
'callbacks' => [
'label' => RawJs::make(<<<'JS'
function(context) {
let label = context.dataset.label || '';
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
label += new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(context.parsed.y);
}
return label;
}
JS),
],
],
],
'interaction' => [
'intersect' => false,
], ],
]; ];
@@ -4,6 +4,7 @@ namespace App\Filament\Widgets;
use App\Filament\Widgets\Data\HelperStatisticType; use App\Filament\Widgets\Data\HelperStatisticType;
use App\Filament\Widgets\Data\LoadEvents; use App\Filament\Widgets\Data\LoadEvents;
// use Filament\Support\RawJs;
use Filament\Widgets\ChartWidget; use Filament\Widgets\ChartWidget;
use Filament\Widgets\Concerns\InteractsWithPageFilters; use Filament\Widgets\Concerns\InteractsWithPageFilters;
@@ -21,6 +22,9 @@ class ChartPunctualEvent extends ChartWidget
'display' => false, 'display' => false,
], ],
], ],
'interaction' => [
'intersect' => false,
],
]; ];
public function getDescription(): ?string public function getDescription(): ?string
@@ -41,4 +45,69 @@ class ChartPunctualEvent extends ChartWidget
{ {
return 'line'; return 'line';
} }
// protected function getOptions(): RawJs|array
// {
// return RawJs::make(<<<'JS'
// {
// plugins: {
// legend: {
// display: false
// },
// datalabels: {
// backgroundColor: function(context) {
// return context.active ? context.dataset.backgroundColor : 'white';
// },
// borderColor: function(context) {
// return context.dataset.backgroundColor;
// },
// borderRadius: function(context) {
// return context.active ? 0 : 32;
// },
// borderWidth: 3,
// color: function(context) {
// return context.active ? 'white' : context.dataset.backgroundColor;
// },
// font: {
// weight: 'bold'
// },
// formatter: function(value, context) {
// value = Math.round(value * 100) / 100;
// return context.active
// ? context.dataset.label + '\n' + value + '%'
// : Math.round(value);
// },
// offset: 8,
// padding: 5,
// textAlign: 'center'
// }
// },
// // Core options
// aspectRatio: 5 / 3,
// layout: {
// padding: {
// bottom: 16,
// right: 40,
// left: 8,
// top: 40
// }
// },
// hover: {
// mode: 'index',
// intersect: false
// },
// elements: {
// line: {
// fill: false,
// tension: 0.4
// }
// },
// scales: {
// y: {
// stacked: true
// }
// }
// }
// JS);
// }
} }
+13 -8
View File
@@ -31,14 +31,17 @@ class LoadEvents
$statistic_type = $filter['statistic_type'] ?? 0; $statistic_type = $filter['statistic_type'] ?? 0;
$team_position = $filter['team_position'];
if (! $league_id) { if (! $league_id) {
return []; return [];
} }
if (! $team_id) { if (! $team_id) {
return []; return [];
} }
if (! $statistic_type) {
$team_position = $filter['team_position']; return [];
}
/** /**
* STATTISTIC DATA * STATTISTIC DATA
@@ -60,7 +63,7 @@ class LoadEvents
})->when($end, function ($query) use ($end) { })->when($end, function ($query) use ($end) {
return $query->where('starttime', '<=', $end); return $query->where('starttime', '<=', $end);
}) })
->orderBy('starttime') ->orderBy('starttime', 'ASC')
->get(); ->get();
// dd($res); // dd($res);
@@ -71,12 +74,10 @@ class LoadEvents
$datasets = []; $datasets = [];
$labels = []; $labels = [];
$labels_since = [];
if (! $statistic_type || $statistic_type == 'none') {
$statistic_type = 'gls';
}
foreach ($res as $value) { foreach ($res as $value) {
$labels[] = $value['starttime']->format('d.M.y'); $labels[] = $value['starttime']->format('d.M.y');
if ($team_position == 'home') { if ($team_position == 'home') {
@@ -189,11 +190,15 @@ class LoadEvents
$data = [ $data = [
'datasets' => [ 'datasets' => [
[ [
'label' => ucfirst($team_position), 'label' => HelperStatisticType::get($filter),
'data' => $datasets, 'data' => $datasets,
'fill' => true, 'fill' => true,
'tension' => 0.5, 'tension' => 0.5,
'borderColor' => '#36A2EB', 'borderColor' => '#36A2EB',
'datalabels' => [
'align' => 'start',
'anchor' => 'start',
],
], ],
], ],
'labels' => $labels, 'labels' => $labels,