Skip to content

Commit

Permalink
[Feature] Fill charts with 10% and make beginAtZero configurable (#1839)
Browse files Browse the repository at this point in the history
* set fill to true and start at zero in config

* fix legend

* Fix conflicts

* ordered config

* Change pointRadius to 24

---------

Co-authored-by: Alex Justesen <[email protected]>
  • Loading branch information
svenvg93 and alexjustesen authored Nov 27, 2024
1 parent fbf271f commit 9e69d7e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
5 changes: 4 additions & 1 deletion app/Filament/Widgets/RecentDownloadChartWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ protected function getData(): array
'borderColor' => 'rgba(14, 165, 233)',
'backgroundColor' => 'rgba(14, 165, 233, 0.1)',
'pointBackgroundColor' => 'rgba(14, 165, 233)',
'fill' => true,
'cubicInterpolationMode' => 'monotone',
'tension' => 0.4,
'pointRadius' => count($results) <= 24 ? 3 : 0,
],
[
'label' => 'Average',
Expand All @@ -82,6 +84,7 @@ protected function getOptions(): array
'plugins' => [
'legend' => [
'display' => true,

],
'tooltip' => [
'enabled' => true,
Expand All @@ -92,7 +95,7 @@ protected function getOptions(): array
],
'scales' => [
'y' => [
'beginAtZero' => true,
'beginAtZero' => config('app.chart_begin_at_zero'),
],
],
];
Expand Down
8 changes: 7 additions & 1 deletion app/Filament/Widgets/RecentDownloadLatencyChartWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,32 @@ protected function getData(): array
'borderColor' => 'rgba(16, 185, 129)',
'backgroundColor' => 'rgba(16, 185, 129, 0.1)',
'pointBackgroundColor' => 'rgba(16, 185, 129)',
'fill' => true,
'cubicInterpolationMode' => 'monotone',
'tension' => 0.4,
'pointRadius' => count($results) <= 24 ? 3 : 0,
],
[
'label' => 'High (ms)',
'data' => $results->map(fn ($item) => $item->download_latency_high),
'borderColor' => 'rgba(14, 165, 233)',
'backgroundColor' => 'rgba(14, 165, 233, 0.1)',
'pointBackgroundColor' => 'rgba(14, 165, 233)',
'fill' => true,
'cubicInterpolationMode' => 'monotone',
'tension' => 0.4,
'pointRadius' => count($results) <= 24 ? 3 : 0,
],
[
'label' => 'Low (ms)',
'data' => $results->map(fn ($item) => $item->download_latency_low),
'borderColor' => 'rgba(139, 92, 246)',
'backgroundColor' => 'rgba(139, 92, 246, 0.1)',
'pointBackgroundColor' => 'rgba(139, 92, 246)',
'fill' => true,
'cubicInterpolationMode' => 'monotone',
'tension' => 0.4,
'pointRadius' => count($results) <= 24 ? 3 : 0,
],
],
'labels' => $results->map(fn ($item) => $item->created_at->timezone(config('app.display_timezone'))->format(config('app.chart_datetime_format'))),
Expand All @@ -97,7 +103,7 @@ protected function getOptions(): array
],
'scales' => [
'y' => [
'beginAtZero' => true,
'beginAtZero' => config('app.chart_begin_at_zero'),
],
],
];
Expand Down
8 changes: 7 additions & 1 deletion app/Filament/Widgets/RecentJitterChartWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,32 @@ protected function getData(): array
'borderColor' => 'rgba(14, 165, 233)',
'backgroundColor' => 'rgba(14, 165, 233, 0.1)',
'pointBackgroundColor' => 'rgba(14, 165, 233)',
'fill' => true,
'cubicInterpolationMode' => 'monotone',
'tension' => 0.4,
'pointRadius' => count($results) <= 24 ? 3 : 0,
],
[
'label' => 'Upload (ms)',
'data' => $results->map(fn ($item) => $item->upload_jitter),
'borderColor' => 'rgba(139, 92, 246)',
'backgroundColor' => 'rgba(139, 92, 246, 0.1)',
'pointBackgroundColor' => 'rgba(139, 92, 246)',
'fill' => true,
'cubicInterpolationMode' => 'monotone',
'tension' => 0.4,
'pointRadius' => count($results) <= 24 ? 3 : 0,
],
[
'label' => 'Ping (ms)',
'data' => $results->map(fn ($item) => $item->ping_jitter),
'borderColor' => 'rgba(16, 185, 129)',
'backgroundColor' => 'rgba(16, 185, 129, 0.1)',
'pointBackgroundColor' => 'rgba(16, 185, 129)',
'fill' => true,
'cubicInterpolationMode' => 'monotone',
'tension' => 0.4,
'pointRadius' => count($results) <= 24 ? 3 : 0,
],
],
'labels' => $results->map(fn ($item) => $item->created_at->timezone(config('app.display_timezone'))->format(config('app.chart_datetime_format'))),
Expand All @@ -97,7 +103,7 @@ protected function getOptions(): array
],
'scales' => [
'y' => [
'beginAtZero' => true,
'beginAtZero' => config('app.chart_begin_at_zero'),
],
],
];
Expand Down
4 changes: 3 additions & 1 deletion app/Filament/Widgets/RecentPingChartWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ protected function getData(): array
'borderColor' => 'rgba(16, 185, 129)',
'backgroundColor' => 'rgba(16, 185, 129, 0.1)',
'pointBackgroundColor' => 'rgba(16, 185, 129)',
'fill' => true,
'cubicInterpolationMode' => 'monotone',
'tension' => 0.4,
'pointRadius' => count($results) <= 24 ? 3 : 0,
],
[
'label' => 'Average',
Expand Down Expand Up @@ -91,7 +93,7 @@ protected function getOptions(): array
],
'scales' => [
'y' => [
'beginAtZero' => true,
'beginAtZero' => config('app.chart_begin_at_zero'),
],
],
];
Expand Down
4 changes: 3 additions & 1 deletion app/Filament/Widgets/RecentUploadChartWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ protected function getData(): array
'borderColor' => 'rgba(139, 92, 246)',
'backgroundColor' => 'rgba(139, 92, 246, 0.1)',
'pointBackgroundColor' => 'rgba(139, 92, 246)',
'fill' => true,
'cubicInterpolationMode' => 'monotone',
'tension' => 0.4,
'pointRadius' => count($results) <= 24 ? 3 : 0,
],
[
'label' => 'Average',
Expand Down Expand Up @@ -92,7 +94,7 @@ protected function getOptions(): array
],
'scales' => [
'y' => [
'beginAtZero' => true,
'beginAtZero' => config('app.chart_begin_at_zero'),
],
],
];
Expand Down
8 changes: 7 additions & 1 deletion app/Filament/Widgets/RecentUploadLatencyChartWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,32 @@ protected function getData(): array
'borderColor' => 'rgba(16, 185, 129)',
'backgroundColor' => 'rgba(16, 185, 129, 0.1)',
'pointBackgroundColor' => 'rgba(16, 185, 129)',
'fill' => true,
'cubicInterpolationMode' => 'monotone',
'tension' => 0.4,
'pointRadius' => count($results) <= 24 ? 3 : 0,
],
[
'label' => 'High (ms)',
'data' => $results->map(fn ($item) => $item->upload_latency_high),
'borderColor' => 'rgba(14, 165, 233)',
'backgroundColor' => 'rgba(14, 165, 233, 0.1)',
'pointBackgroundColor' => 'rgba(14, 165, 233)',
'fill' => true,
'cubicInterpolationMode' => 'monotone',
'tension' => 0.4,
'pointRadius' => count($results) <= 24 ? 3 : 0,
],
[
'label' => 'Low (ms)',
'data' => $results->map(fn ($item) => $item->upload_latency_low),
'borderColor' => 'rgba(139, 92, 246)',
'backgroundColor' => 'rgba(139, 92, 246, 0.1)',
'pointBackgroundColor' => 'rgba(139, 92, 246)',
'fill' => true,
'cubicInterpolationMode' => 'monotone',
'tension' => 0.4,
'pointRadius' => count($results) <= 24 ? 3 : 0,
],
],
'labels' => $results->map(fn ($item) => $item->created_at->timezone(config('app.display_timezone'))->format(config('app.chart_datetime_format'))),
Expand All @@ -97,7 +103,7 @@ protected function getOptions(): array
],
'scales' => [
'y' => [
'beginAtZero' => true,
'beginAtZero' => config('app.chart_begin_at_zero'),
],
],
];
Expand Down
2 changes: 2 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

'env' => env('APP_ENV', 'production'),

'chart_begin_at_zero' => env('CHART_BEGIN_AT_ZERO', true),

'chart_datetime_format' => env('CHART_DATETIME_FORMAT', 'M. j - G:i'),

'datetime_format' => env('DATETIME_FORMAT', 'M. jS, Y g:ia'),
Expand Down

0 comments on commit 9e69d7e

Please sign in to comment.