wip statistic events quasi
This commit is contained in:
1 parent
897a327709
commit
58b9abbd32
6 files changed
+106
-25
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Actions\LoadStatisticFixturesLeaguesOptions;
|
||||
use App\Filament\Widgets\MedianAverageWidget;
|
||||
use App\Filament\Widgets\MovingAverageChart;
|
||||
use App\Filament\Widgets\PunctualChart;
|
||||
use App\Models\Element;
|
||||
@@ -61,8 +62,12 @@ class Statistic extends BaseDashboard
|
||||
->preload()
|
||||
->searchable()
|
||||
->label('Team'),
|
||||
DatePicker::make('startDate'),
|
||||
DatePicker::make('endDate'),
|
||||
DatePicker::make('startDate')
|
||||
->native(false)
|
||||
->prefixIcon('phosphor-calendar'),
|
||||
DatePicker::make('endDate')
|
||||
->native(false)
|
||||
->prefixIcon('phosphor-calendar'),
|
||||
])->columns(4)
|
||||
->columnSpanFull(),
|
||||
Section::make()
|
||||
@@ -145,6 +150,7 @@ class Statistic extends BaseDashboard
|
||||
protected function getFooterWidgets(): array
|
||||
{
|
||||
return [
|
||||
MedianAverageWidget::make(),
|
||||
PunctualChart::make(),
|
||||
MovingAverageChart::make(),
|
||||
];
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Actions\Statistics\LoadEvents;
|
||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||
use Filament\Widgets\StatsOverviewWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
|
||||
class MedianAverageWidget extends StatsOverviewWidget
|
||||
{
|
||||
use InteractsWithPageFilters;
|
||||
|
||||
protected function getStats(): array
|
||||
{
|
||||
$data = LoadEvents::load($this->filters);
|
||||
|
||||
if (! isset($data['datasets'][0])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$arr = $data['datasets'][0]['data'];
|
||||
$total = count($arr);
|
||||
$summe = array_sum($arr);
|
||||
|
||||
if (! $total) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($total % 2) {
|
||||
$m = $total / 2 + 1;
|
||||
$median = $arr[$m];
|
||||
} else {
|
||||
$m = $total / 2;
|
||||
$m1 = floor($m);
|
||||
$m2 = ceil($m);
|
||||
$median = round(($arr[$m1] + $arr[$m2]) / 2, 2);
|
||||
}
|
||||
|
||||
return [
|
||||
Stat::make('Number of events', $total),
|
||||
Stat::make('Average', round($summe / $total, 2)),
|
||||
Stat::make('Median', $median),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,14 @@ class MovingAverageChart extends ChartWidget
|
||||
|
||||
public ?string $header;
|
||||
|
||||
protected ?array $options = [
|
||||
'plugins' => [
|
||||
'legend' => [
|
||||
'display' => false,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return 'Moving Average';
|
||||
|
||||
@@ -12,15 +12,18 @@ class PunctualChart extends ChartWidget
|
||||
{
|
||||
use InteractsWithPageFilters;
|
||||
|
||||
/**
|
||||
* 1. Ein Diagramm, das die Werte des ausgewählten Feldes GRUPPE 2 (HEIM/AUSWÄRTS/VERANSTALTUNG) darstellt,
|
||||
* mit dem Punktwert auf der Ordinate und dem aufsteigenden Datum auf der Abszisse,
|
||||
* und das den Mittelwert und den Medianwert für die ausgewählte Statistik an den ausgewählten Daten enthält.
|
||||
*/
|
||||
protected ?string $pollingInterval = null;
|
||||
|
||||
public ?string $header;
|
||||
|
||||
protected ?array $options = [
|
||||
'plugins' => [
|
||||
'legend' => [
|
||||
'display' => false,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return 'Punctual';
|
||||
|
||||
Reference in new issue
Block a user