Skip to content

Commit 9e69d7e

Browse files
[Feature] Fill charts with 10% and make beginAtZero configurable (alexjustesen#1839)
* 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]>
1 parent fbf271f commit 9e69d7e

File tree

7 files changed

+33
-6
lines changed

7 files changed

+33
-6
lines changed

app/Filament/Widgets/RecentDownloadChartWidget.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ protected function getData(): array
5757
'borderColor' => 'rgba(14, 165, 233)',
5858
'backgroundColor' => 'rgba(14, 165, 233, 0.1)',
5959
'pointBackgroundColor' => 'rgba(14, 165, 233)',
60+
'fill' => true,
6061
'cubicInterpolationMode' => 'monotone',
6162
'tension' => 0.4,
63+
'pointRadius' => count($results) <= 24 ? 3 : 0,
6264
],
6365
[
6466
'label' => 'Average',
@@ -82,6 +84,7 @@ protected function getOptions(): array
8284
'plugins' => [
8385
'legend' => [
8486
'display' => true,
87+
8588
],
8689
'tooltip' => [
8790
'enabled' => true,
@@ -92,7 +95,7 @@ protected function getOptions(): array
9295
],
9396
'scales' => [
9497
'y' => [
95-
'beginAtZero' => true,
98+
'beginAtZero' => config('app.chart_begin_at_zero'),
9699
],
97100
],
98101
];

app/Filament/Widgets/RecentDownloadLatencyChartWidget.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,32 @@ protected function getData(): array
5555
'borderColor' => 'rgba(16, 185, 129)',
5656
'backgroundColor' => 'rgba(16, 185, 129, 0.1)',
5757
'pointBackgroundColor' => 'rgba(16, 185, 129)',
58+
'fill' => true,
5859
'cubicInterpolationMode' => 'monotone',
5960
'tension' => 0.4,
61+
'pointRadius' => count($results) <= 24 ? 3 : 0,
6062
],
6163
[
6264
'label' => 'High (ms)',
6365
'data' => $results->map(fn ($item) => $item->download_latency_high),
6466
'borderColor' => 'rgba(14, 165, 233)',
6567
'backgroundColor' => 'rgba(14, 165, 233, 0.1)',
6668
'pointBackgroundColor' => 'rgba(14, 165, 233)',
69+
'fill' => true,
6770
'cubicInterpolationMode' => 'monotone',
6871
'tension' => 0.4,
72+
'pointRadius' => count($results) <= 24 ? 3 : 0,
6973
],
7074
[
7175
'label' => 'Low (ms)',
7276
'data' => $results->map(fn ($item) => $item->download_latency_low),
7377
'borderColor' => 'rgba(139, 92, 246)',
7478
'backgroundColor' => 'rgba(139, 92, 246, 0.1)',
7579
'pointBackgroundColor' => 'rgba(139, 92, 246)',
80+
'fill' => true,
7681
'cubicInterpolationMode' => 'monotone',
7782
'tension' => 0.4,
83+
'pointRadius' => count($results) <= 24 ? 3 : 0,
7884
],
7985
],
8086
'labels' => $results->map(fn ($item) => $item->created_at->timezone(config('app.display_timezone'))->format(config('app.chart_datetime_format'))),
@@ -97,7 +103,7 @@ protected function getOptions(): array
97103
],
98104
'scales' => [
99105
'y' => [
100-
'beginAtZero' => true,
106+
'beginAtZero' => config('app.chart_begin_at_zero'),
101107
],
102108
],
103109
];

app/Filament/Widgets/RecentJitterChartWidget.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,32 @@ protected function getData(): array
5555
'borderColor' => 'rgba(14, 165, 233)',
5656
'backgroundColor' => 'rgba(14, 165, 233, 0.1)',
5757
'pointBackgroundColor' => 'rgba(14, 165, 233)',
58+
'fill' => true,
5859
'cubicInterpolationMode' => 'monotone',
5960
'tension' => 0.4,
61+
'pointRadius' => count($results) <= 24 ? 3 : 0,
6062
],
6163
[
6264
'label' => 'Upload (ms)',
6365
'data' => $results->map(fn ($item) => $item->upload_jitter),
6466
'borderColor' => 'rgba(139, 92, 246)',
6567
'backgroundColor' => 'rgba(139, 92, 246, 0.1)',
6668
'pointBackgroundColor' => 'rgba(139, 92, 246)',
69+
'fill' => true,
6770
'cubicInterpolationMode' => 'monotone',
6871
'tension' => 0.4,
72+
'pointRadius' => count($results) <= 24 ? 3 : 0,
6973
],
7074
[
7175
'label' => 'Ping (ms)',
7276
'data' => $results->map(fn ($item) => $item->ping_jitter),
7377
'borderColor' => 'rgba(16, 185, 129)',
7478
'backgroundColor' => 'rgba(16, 185, 129, 0.1)',
7579
'pointBackgroundColor' => 'rgba(16, 185, 129)',
80+
'fill' => true,
7681
'cubicInterpolationMode' => 'monotone',
7782
'tension' => 0.4,
83+
'pointRadius' => count($results) <= 24 ? 3 : 0,
7884
],
7985
],
8086
'labels' => $results->map(fn ($item) => $item->created_at->timezone(config('app.display_timezone'))->format(config('app.chart_datetime_format'))),
@@ -97,7 +103,7 @@ protected function getOptions(): array
97103
],
98104
'scales' => [
99105
'y' => [
100-
'beginAtZero' => true,
106+
'beginAtZero' => config('app.chart_begin_at_zero'),
101107
],
102108
],
103109
];

app/Filament/Widgets/RecentPingChartWidget.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ protected function getData(): array
5656
'borderColor' => 'rgba(16, 185, 129)',
5757
'backgroundColor' => 'rgba(16, 185, 129, 0.1)',
5858
'pointBackgroundColor' => 'rgba(16, 185, 129)',
59+
'fill' => true,
5960
'cubicInterpolationMode' => 'monotone',
6061
'tension' => 0.4,
62+
'pointRadius' => count($results) <= 24 ? 3 : 0,
6163
],
6264
[
6365
'label' => 'Average',
@@ -91,7 +93,7 @@ protected function getOptions(): array
9193
],
9294
'scales' => [
9395
'y' => [
94-
'beginAtZero' => true,
96+
'beginAtZero' => config('app.chart_begin_at_zero'),
9597
],
9698
],
9799
];

app/Filament/Widgets/RecentUploadChartWidget.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ protected function getData(): array
5757
'borderColor' => 'rgba(139, 92, 246)',
5858
'backgroundColor' => 'rgba(139, 92, 246, 0.1)',
5959
'pointBackgroundColor' => 'rgba(139, 92, 246)',
60+
'fill' => true,
6061
'cubicInterpolationMode' => 'monotone',
6162
'tension' => 0.4,
63+
'pointRadius' => count($results) <= 24 ? 3 : 0,
6264
],
6365
[
6466
'label' => 'Average',
@@ -92,7 +94,7 @@ protected function getOptions(): array
9294
],
9395
'scales' => [
9496
'y' => [
95-
'beginAtZero' => true,
97+
'beginAtZero' => config('app.chart_begin_at_zero'),
9698
],
9799
],
98100
];

app/Filament/Widgets/RecentUploadLatencyChartWidget.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,32 @@ protected function getData(): array
5555
'borderColor' => 'rgba(16, 185, 129)',
5656
'backgroundColor' => 'rgba(16, 185, 129, 0.1)',
5757
'pointBackgroundColor' => 'rgba(16, 185, 129)',
58+
'fill' => true,
5859
'cubicInterpolationMode' => 'monotone',
5960
'tension' => 0.4,
61+
'pointRadius' => count($results) <= 24 ? 3 : 0,
6062
],
6163
[
6264
'label' => 'High (ms)',
6365
'data' => $results->map(fn ($item) => $item->upload_latency_high),
6466
'borderColor' => 'rgba(14, 165, 233)',
6567
'backgroundColor' => 'rgba(14, 165, 233, 0.1)',
6668
'pointBackgroundColor' => 'rgba(14, 165, 233)',
69+
'fill' => true,
6770
'cubicInterpolationMode' => 'monotone',
6871
'tension' => 0.4,
72+
'pointRadius' => count($results) <= 24 ? 3 : 0,
6973
],
7074
[
7175
'label' => 'Low (ms)',
7276
'data' => $results->map(fn ($item) => $item->upload_latency_low),
7377
'borderColor' => 'rgba(139, 92, 246)',
7478
'backgroundColor' => 'rgba(139, 92, 246, 0.1)',
7579
'pointBackgroundColor' => 'rgba(139, 92, 246)',
80+
'fill' => true,
7681
'cubicInterpolationMode' => 'monotone',
7782
'tension' => 0.4,
83+
'pointRadius' => count($results) <= 24 ? 3 : 0,
7884
],
7985
],
8086
'labels' => $results->map(fn ($item) => $item->created_at->timezone(config('app.display_timezone'))->format(config('app.chart_datetime_format'))),
@@ -97,7 +103,7 @@ protected function getOptions(): array
97103
],
98104
'scales' => [
99105
'y' => [
100-
'beginAtZero' => true,
106+
'beginAtZero' => config('app.chart_begin_at_zero'),
101107
],
102108
],
103109
];

config/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

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

9+
'chart_begin_at_zero' => env('CHART_BEGIN_AT_ZERO', true),
10+
911
'chart_datetime_format' => env('CHART_DATETIME_FORMAT', 'M. j - G:i'),
1012

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

0 commit comments

Comments
 (0)