wip tooltip with events

This commit is contained in:
salam committed 2026-05-25 13:05:11 +02:00
1 parent 06dbeb1ed8
commit ec9e380d33
4 files changed
+73 -36

No files matched your search

@@ -5,6 +5,7 @@ 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;
@@ -14,22 +15,6 @@ class ChartMovingAverageEvent extends ChartWidget
protected ?string $pollingInterval = null;
protected ?array $options = [
'plugins' => [
'legend' => [
'display' => true,
],
],
'interaction' => [
'intersect' => false,
],
'scales' => [
'y' => [
'beginAtZero' => true,
],
],
];
protected function getData(): array
{
$this->heading = 'Events '.HelperStatisticType::get($this->filters);
@@ -49,4 +34,29 @@ class ChartMovingAverageEvent extends ChartWidget
{
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);
}
}
+26 -16
View File
@@ -4,6 +4,7 @@ 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;
@@ -13,22 +14,6 @@ class ChartPunctualEvent extends ChartWidget
protected ?string $pollingInterval = null;
protected ?array $options = [
'plugins' => [
'legend' => [
'display' => true,
],
],
'interaction' => [
'intersect' => false,
],
'scales' => [
'y' => [
'beginAtZero' => true,
],
],
];
protected function getData(): array
{
$this->heading = 'Events '.HelperStatisticType::get($this->filters);
@@ -46,4 +31,29 @@ class ChartPunctualEvent extends ChartWidget
{
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);
}
}
@@ -24,6 +24,11 @@ class ChartPunctualPlayer extends ChartWidget
'interaction' => [
'intersect' => false,
],
'callbacks' => [
'label' => 'function(context) {
return " Count: " + context.raw;
}',
],
];
public function getDescription(): ?string
+16 -4
View File
@@ -76,7 +76,9 @@ class LoadEvents
/**
* STATTISTIC DATA
*/
$res = StatistikoEvent::where('league_id', $league_id)
$res = StatistikoEvent::with('home')
->with('away')
->where('league_id', $league_id)
->where(function ($query) use ($team_id, $team_position) {
switch ($team_position) {
case 'home':
@@ -104,9 +106,17 @@ class LoadEvents
$dataset_home = [];
$dataset_away = [];
$labels = [];
$events = [];
$labels_since = [];
$results = ['w' => 0, 'd' => 0, 'l' => 0];
/**
* IF WITH PLAYER
*/
// $res = StatisticFixtures::with('home')->with('away')->where('id', (int) $match_id)->first();
// $event = $res->home->name.' vs '.$res->away->name;
// dd($event);
foreach ($res as $value) {
$labels[] = $value['starttime']->format('d.M.y');
@@ -286,6 +296,7 @@ class LoadEvents
}
}
if (isset($val_home) && isset($val_away)) {
$events[] = $value->home->name.' vs '.$value->away->name;
$dataset_home[] = $val_home;
$dataset_away[] = $val_away;
}
@@ -294,15 +305,16 @@ class LoadEvents
$data = [
'datasets' => [
[
'label' => 'Home',
'label' => 'In Favor',
'events' => $events,
'data' => $dataset_home,
'fill' => false,
'tension' => 0.5,
'borderColor' => '#36A2EB',
],
[
// 'label' => 'Away '.HelperStatisticType::get($filter),
'label' => 'Away',
'label' => 'Against',
'events' => $events,
'data' => $dataset_away,
'fill' => false,
'tension' => 0.5,