From e884874dd7b8e4301cd0a4445f093b888bb4ab62 Mon Sep 17 00:00:00 2001 From: Leandro Costa Ferreira Date: Wed, 7 Dec 2022 11:16:09 -0300 Subject: [PATCH 1/9] phpstan errors fixed --- composer.json | 3 +-- phpstan.neon.dist | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 0d8480c..321088a 100644 --- a/composer.json +++ b/composer.json @@ -35,8 +35,7 @@ }, "autoload": { "psr-4": { - "Leandrocfe\\FilamentApexCharts\\": "src", - "Leandrocfe\\FilamentApexCharts\\Database\\Factories\\": "database/factories" + "Leandrocfe\\FilamentApexCharts\\": "src" } }, "autoload-dev": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a91953b..e005ac7 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -6,7 +6,6 @@ parameters: paths: - src - config - - database tmpDir: build/phpstan checkOctaneCompatibility: true checkModelProperties: true From c654e3d1c656784ff4c16816c9459a488d1876b3 Mon Sep 17 00:00:00 2001 From: Leandro Costa Ferreira Date: Wed, 7 Dec 2022 15:37:17 -0300 Subject: [PATCH 2/9] documentation based on new chart features --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++----- examples/README.md | 47 ++++++++++++++++++++++++++---------------- 2 files changed, 75 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 24947e2..ab41665 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,34 @@ Start by creating a widget with the command: php artisan make:filament-apex-charts BlogPostsChart ``` -This command will create the BlogPostsChart.php file in app\Filament\Widgets: +### Available chart samples + +You may choose: + +- Area +- Bar +- Boxplot +- Bubble +- Candlestick +- Column +- Donut +- Heatmap +- Line +- Mixed-LineAndColumn +- Pie +- PolarArea +- Radar +- Radialbar +- RangeArea +- Scatter +- TimelineRangeBars +- Treemap + +You may also create an **empty chart** by selecting the **Empty** option. + +This command will create the **BlogPostsChart.php** file in _app\Filament\Widgets_. Ex: ```php - namespace App\Filament\Widgets; use Leandrocfe\FilamentApexCharts\Widgets\ApexChartWidget; @@ -61,22 +85,39 @@ class BlogPostsChart extends ApexChartWidget return [ 'chart' => [ 'type' => 'bar', + 'height' => 300, ], 'series' => [ [ - 'name' => 'Sales', - 'data' => [90, 80, 70, 60, 50, 40, 40, 50, 60, 70, 80, 90], + 'name' => 'BlogPostsChart', + 'data' => [7, 4, 6, 10, 14, 7, 5, 9, 10, 15, 13, 18], ], ], 'xaxis' => [ 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'colors' => ['#6366f1'], ]; } } + ``` -Now, check out your widget in the **dashboard**. +Now, check out your new widget in the **dashboard**. ## Available options diff --git a/examples/README.md b/examples/README.md index 0d07494..cce5362 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,33 +1,44 @@ # Examples -You may copy the file and paste it into _app\Filament\Widgets_ folder. Once you have pasted the widget file, check out your widget on the **dashboard** page. +You may copy the file and paste it into **app\Filament\Widgets** folder. Once you have pasted the widget file, check out your widget on the **dashboard** page. -- Line - - [Basic Line Chart](Line/BasicLineChart.php) - - [Line Column Chart](Mixed/LineColumnChart.php) -- Column - - [Basic Column Chart](Column/BasicColumnChart.php) - - [Line Column Chart](Mixed/LineColumnChart.php) - Area - [Basic Area Chart](Area/BasicAreaChart.php) - Bar - [Basic Bar Chart](Bar/BasicBarChart.php) -- Mixed - - [Line Column Chart](Mixed/LineColumnChart.php) -- Range Area -- Timeline Range-bars -- Candlestick - Boxplot + - [Basic Boxplot Chart](Boxplot/BasicBloxPlotChart.php) - Bubble -- Scatter + - [Basic Bubble Chart](Bubble/BasicBubbleChart.php) +- Candlestick + - [Basic Candlestick Chart](Candlestick/BasicCandlestickChart.php) +- Column + - [Basic Column Chart](Column/BasicColumnChart.php) + - [Column + Line Chart](Mixed/LineColumnChart.php) + - [Gradient Column Chart](Column/GradientColumnChart.php) + - [Column Chart with Annotations](Column/ColumnChartWithAnnotations.php) - Heatmap -- Treemap + - [Basic Heatmap Chart](Heatmap/BasicHeatmapChart.php) +- Line + - [Basic Line Chart](Line/BasicLineChart.php) + - [Line + Column Chart](Mixed/LineColumnChart.php) +- Mixed + - [Line + Column Chart](Mixed/LineColumnChart.php) - Pie - [Basic Pie Chart](Pie/BasicPieChart.php) - [Donut Chart](Pie/DonutChart.php) -- Radialbar - - [Gradient Circle Chart](Radialbar/GradientCircleChart.php) -- Radar - - [Basic Radar Chart](Radar/BasicRadarChart.php) - Polar Area - [Basic Polar Area Chart](PolarArea/BasicPolarAreaChart.php) +- Radar + - [Basic Radar Chart](Radar/BasicRadarChart.php) +- Radialbar + - [Basic Radialbar Chart](Radialbar/BasicRadialBarChart.php) + - [Gradient Circle Chart](Radialbar/GradientCircleChart.php) +- Range Area + - [Range Area Chart](RangeArea/BasicRangeAreaChart.php) +- Scatter + - [Basic Scatter Chart](Scatter/BasicScatterChart.php) +- Timeline Range-bars + - [Timeline Bar Chart](TimelineRangeBars/BasicTimelineRangeBarsChart.php) +- Treemap + - [Basic Treemap Chart](Treemap/BasicTreemapChart.php) From 98a9051376cbb37d2a93b697eb908e2533aee9b4 Mon Sep 17 00:00:00 2001 From: Leandro Costa Ferreira Date: Wed, 7 Dec 2022 15:38:42 -0300 Subject: [PATCH 3/9] new chart examples --- config/filament-apex-charts.php | 22 +++++ examples/Area/BasicAreaChart.php | 16 +++- examples/Bar/BasicBarChart.php | 18 ++++- examples/Boxplot/BasicBloxPlotChart.php | 74 +++++++++++++++++ examples/Bubble/BasicBubbleChart.php | 72 +++++++++++++++++ .../Candlestick/BasicCandlestickChart.php | 66 +++++++++++++++ examples/Column/BasicColumnChart.php | 16 +++- .../Column/ColumnChartWithAnnotations.php | 81 +++++++++++++++++++ examples/Column/GradientColumnChart.php | 75 +++++++++++++++++ examples/Column/RoundedColumnChart.php | 68 ++++++++++++++++ examples/Heatmap/BasicHeatmapChart.php | 66 +++++++++++++++ examples/Line/BasicLineChart.php | 14 ++++ examples/Mixed/LineColumnChart.php | 32 ++++++-- examples/Pie/BasicPieChart.php | 6 ++ examples/Pie/DonutChart.php | 6 ++ examples/PolarArea/BasicPolarAreaChart.php | 17 ++++ examples/Radar/BasicRadarChart.php | 14 ++++ examples/Radialbar/BasicRadialBarChart.php | 66 +++++++++++++++ examples/RangeArea/BasicRangeAreaChart.php | 80 ++++++++++++++++++ examples/Scatter/BasicScatterChart.php | 76 +++++++++++++++++ .../BasicTimelineRangeBarsChart.php | 73 +++++++++++++++++ examples/Treemap/BasicTreemapChart.php | 52 ++++++++++++ 22 files changed, 1001 insertions(+), 9 deletions(-) create mode 100644 examples/Boxplot/BasicBloxPlotChart.php create mode 100644 examples/Bubble/BasicBubbleChart.php create mode 100644 examples/Candlestick/BasicCandlestickChart.php create mode 100644 examples/Column/ColumnChartWithAnnotations.php create mode 100644 examples/Column/GradientColumnChart.php create mode 100644 examples/Column/RoundedColumnChart.php create mode 100644 examples/Heatmap/BasicHeatmapChart.php create mode 100644 examples/Radialbar/BasicRadialBarChart.php create mode 100644 examples/RangeArea/BasicRangeAreaChart.php create mode 100644 examples/Scatter/BasicScatterChart.php create mode 100644 examples/TimelineRangeBars/BasicTimelineRangeBarsChart.php create mode 100644 examples/Treemap/BasicTreemapChart.php diff --git a/config/filament-apex-charts.php b/config/filament-apex-charts.php index 9f7958a..4044df4 100644 --- a/config/filament-apex-charts.php +++ b/config/filament-apex-charts.php @@ -3,4 +3,26 @@ // config for Leandrocfe/FilamentApexCharts return [ + //command options + 'chart_options' => [ + 'Empty', + 'Area', + 'Bar', + 'Boxplot', + 'Bubble', + 'Candlestick', + 'Column', + 'Donut', + 'Heatmap', + 'Line', + 'Mixed-LineAndColumn', + 'Pie', + 'PolarArea', + 'Radar', + 'Radialbar', + 'RangeArea', + 'Scatter', + 'TimelineRangeBars', + 'Treemap', + ], ]; diff --git a/examples/Area/BasicAreaChart.php b/examples/Area/BasicAreaChart.php index d1a7897..1aab865 100644 --- a/examples/Area/BasicAreaChart.php +++ b/examples/Area/BasicAreaChart.php @@ -36,11 +36,25 @@ protected function getOptions(): array 'series' => [ [ 'name' => 'BasicAreaChart', - 'data' => [2, 4, 6, 10, 14, 7, 2, 9, 10, 15, 13, 18], + 'data' => [7, 4, 6, 10, 14, 7, 5, 9, 10, 15, 13, 18], ], ], 'xaxis' => [ 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], ], 'colors' => ['#6366f1'], 'stroke' => [ diff --git a/examples/Bar/BasicBarChart.php b/examples/Bar/BasicBarChart.php index 3f9f517..77a00c2 100644 --- a/examples/Bar/BasicBarChart.php +++ b/examples/Bar/BasicBarChart.php @@ -36,16 +36,30 @@ protected function getOptions(): array 'series' => [ [ 'name' => 'BasicBarChart', - 'data' => [2, 4, 6, 10, 14], + 'data' => [7, 10, 13, 15, 18], ], ], 'xaxis' => [ 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], ], 'colors' => ['#6366f1'], 'plotOptions' => [ 'bar' => [ - 'borderRadius' => 4, + 'borderRadius' => 3, 'horizontal' => true, ], ], diff --git a/examples/Boxplot/BasicBloxPlotChart.php b/examples/Boxplot/BasicBloxPlotChart.php new file mode 100644 index 0000000..d702eb5 --- /dev/null +++ b/examples/Boxplot/BasicBloxPlotChart.php @@ -0,0 +1,74 @@ + [ + 'type' => 'boxPlot', + 'height' => 300, + ], + 'series' => [ + [ + 'type' => 'boxPlot', + 'data' => [ + ['x' => 'Jan', 'y' => [54, 66, 69, 75, 88]], + ['x' => 'Fev', 'y' => [43, 65, 69, 76, 81]], + ['x' => 'Mar', 'y' => [31, 39, 45, 51, 59]], + ['x' => 'Apr', 'y' => [39, 46, 55, 65, 71]], + ['x' => 'May', 'y' => [29, 31, 35, 39, 44]], + ], + ], + ], + 'xaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'plotOptions' => [ + 'boxPlot' => [ + 'colors' => [ + 'upper' => '#6366f1', + 'lower' => '#84cc16', + ], + ], + ], + ]; + } +} diff --git a/examples/Bubble/BasicBubbleChart.php b/examples/Bubble/BasicBubbleChart.php new file mode 100644 index 0000000..29bf427 --- /dev/null +++ b/examples/Bubble/BasicBubbleChart.php @@ -0,0 +1,72 @@ + [ + 'type' => 'bubble', + 'height' => 300, + ], + 'series' => [ + ['name' => 'Jan', 'data' => [[49, 12, 10], [24, 31, 10], [54, 20, 14], [52, 25, 67], [13, 69, 53], [55, 61, 55], [13, 70, 41], [45, 56, 61], [60, 21, 23], [48, 30, 69]]], + ['name' => 'Feb', 'data' => [[70, 53, 16], [39, 33, 53], [14, 55, 51], [44, 28, 32], [26, 46, 33], [61, 56, 11], [11, 29, 29], [19, 64, 67], [26, 19, 28], [28, 69, 44]]], + ['name' => 'Mar', 'data' => [[63, 62, 50], [12, 37, 12], [30, 35, 25], [29, 16, 35], [67, 34, 36], [67, 19, 23], [21, 44, 48], [14, 50, 60], [61, 63, 51], [19, 33, 22]]], + ['name' => 'Apr', 'data' => [[22, 14, 29], [57, 12, 63], [65, 63, 61], [56, 27, 44], [61, 54, 41], [43, 69, 12], [65, 68, 42], [56, 33, 42], [46, 48, 12], [54, 56, 12]]], + ['name' => 'May', 'data' => [[57, 68, 50], [22, 37, 32], [33, 46, 18], [51, 14, 39], [23, 63, 60], [65, 24, 38], [67, 33, 59], [19, 62, 24], [19, 55, 24], [12, 20, 32]]], + ], + 'xaxis' => [ + 'min' => 5, + 'max' => 80, + 'type' => 'category', + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'min' => 5, + 'max' => 80, + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'fill' => [ + 'opacity' => 0.7, + ], + 'dataLabels' => [ + 'enabled' => false, + ], + ]; + } +} diff --git a/examples/Candlestick/BasicCandlestickChart.php b/examples/Candlestick/BasicCandlestickChart.php new file mode 100644 index 0000000..1f9bf22 --- /dev/null +++ b/examples/Candlestick/BasicCandlestickChart.php @@ -0,0 +1,66 @@ + [ + 'type' => 'candlestick', + 'height' => 300, + ], + 'series' => [ + [ + 'type' => 'candlestick', + 'data' => [ + ['x' => 'Jan', 'y' => [6629.81, 6650.5, 6623.04, 6633.33]], + ['x' => 'Fev', 'y' => [6632.01, 6643.59, 6620, 6630.11]], + ['x' => 'Mar', 'y' => [6630.71, 6648.95, 6623.34, 6635.65]], + ['x' => 'Apr', 'y' => [6635.65, 6651, 6629.67, 6638.24]], + ['x' => 'May', 'y' => [6638.24, 6640, 6620, 6624.47]], + ], + ], + ], + 'xaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + ]; + } +} diff --git a/examples/Column/BasicColumnChart.php b/examples/Column/BasicColumnChart.php index afcc865..a6d76e7 100644 --- a/examples/Column/BasicColumnChart.php +++ b/examples/Column/BasicColumnChart.php @@ -36,11 +36,25 @@ protected function getOptions(): array 'series' => [ [ 'name' => 'BasicColumnChart', - 'data' => [2, 4, 6, 10, 14, 7, 2, 9, 10, 15, 13, 18], + 'data' => [7, 4, 6, 10, 14, 7, 5, 9, 10, 15, 13, 18], ], ], 'xaxis' => [ 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], ], 'colors' => ['#6366f1'], ]; diff --git a/examples/Column/ColumnChartWithAnnotations.php b/examples/Column/ColumnChartWithAnnotations.php new file mode 100644 index 0000000..a3bde56 --- /dev/null +++ b/examples/Column/ColumnChartWithAnnotations.php @@ -0,0 +1,81 @@ + [ + 'type' => 'bar', + 'height' => 300, + ], + 'series' => [ + [ + 'name' => 'ColumnChartWithAnnotations', + 'data' => [7, 4, 6, 10, 14, 7, 5, 9, 10, 15, 13, 18], + ], + ], + 'xaxis' => [ + 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'colors' => ['#6366f1'], + 'annotations' => [ + 'yaxis' => [ + [ + 'y' => 15, + 'borderColor' => '#fcd34d', + 'borderWidth' => '5', + 'label' => [ + 'offsetX' => -5, + 'offsetY' => -13, + 'borderColor' => '#f59e0b', + 'style' => [ + 'color' => '#fffbeb', + 'background' => '#f59e0b', + ], + 'text' => 'Label Example', + ], + ], + ], + ], + ]; + } +} diff --git a/examples/Column/GradientColumnChart.php b/examples/Column/GradientColumnChart.php new file mode 100644 index 0000000..9fdba63 --- /dev/null +++ b/examples/Column/GradientColumnChart.php @@ -0,0 +1,75 @@ + [ + 'type' => 'bar', + 'height' => 300, + ], + 'series' => [ + [ + 'name' => 'GradientColumnChart', + 'data' => [7, 4, 6, 10, 14, 7, 5, 9, 10, 15, 13, 18], + ], + ], + 'xaxis' => [ + 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'colors' => ['#6366f1'], + 'fill' => [ + 'type' => 'gradient', + 'gradient' => [ + 'shade' => 'dark', + 'type' => 'vertical', + 'shadeIntensity' => 0.5, + 'gradientToColors' => ['#34d399'], + 'inverseColors' => true, + 'opacityFrom' => 1, + 'opacityTo' => 1, + 'stops' => [0, 100], + ], + ], + ]; + } +} diff --git a/examples/Column/RoundedColumnChart.php b/examples/Column/RoundedColumnChart.php new file mode 100644 index 0000000..66a6ca8 --- /dev/null +++ b/examples/Column/RoundedColumnChart.php @@ -0,0 +1,68 @@ + [ + 'type' => 'bar', + 'height' => 300, + ], + 'series' => [ + [ + 'name' => 'RoundedColumnChart', + 'data' => [7, 4, 6, 10, 14, 7, 5, 9, 10, 15, 13, 18], + ], + ], + 'xaxis' => [ + 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'colors' => ['#6366f1'], + 'plotOptions' => [ + 'bar' => [ + 'borderRadius' => 10, + 'columnWidth' => '65%', + ], + ], + ]; + } +} diff --git a/examples/Heatmap/BasicHeatmapChart.php b/examples/Heatmap/BasicHeatmapChart.php new file mode 100644 index 0000000..f09fb78 --- /dev/null +++ b/examples/Heatmap/BasicHeatmapChart.php @@ -0,0 +1,66 @@ + [ + 'type' => 'heatmap', + 'height' => 300, + ], + 'series' => [ + ['name' => 'Jan', 'data' => [[55, 70], [33, 42], [68, 40], [40, 48], [63, 19], [38, 23]]], + ['name' => 'Feb', 'data' => [[44, 38], [37, 47], [16, 52], [30, 27], [46, 55], [37, 13]]], + ['name' => 'Mar', 'data' => [[10, 42], [30, 16], [54, 34], [31, 47], [30, 31], [58, 60]]], + ['name' => 'Apr', 'data' => [[14, 60], [50, 30], [64, 13], [34, 32], [41, 23], [15, 70]]], + ['name' => 'May', 'data' => [[66, 69], [42, 20], [47, 34], [12, 37], [59, 29], [25, 60]]], + ], + 'xaxis' => [ + 'type' => 'category', + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'dataLabels' => [ + 'enabled' => false, + ], + 'colors' => ['#6366f1'], + ]; + } +} diff --git a/examples/Line/BasicLineChart.php b/examples/Line/BasicLineChart.php index d9b2fcb..6c36455 100644 --- a/examples/Line/BasicLineChart.php +++ b/examples/Line/BasicLineChart.php @@ -41,6 +41,20 @@ protected function getOptions(): array ], 'xaxis' => [ 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], ], 'colors' => ['#6366f1'], 'stroke' => [ diff --git a/examples/Mixed/LineColumnChart.php b/examples/Mixed/LineColumnChart.php index 23332a4..6b891d8 100644 --- a/examples/Mixed/LineColumnChart.php +++ b/examples/Mixed/LineColumnChart.php @@ -29,6 +29,10 @@ class LineColumnChart extends ApexChartWidget protected function getOptions(): array { return [ + 'chart' => [ + 'type' => 'line', + 'height' => 300, + ], 'series' => [ [ 'name' => 'Column', @@ -41,14 +45,32 @@ protected function getOptions(): array 'type' => 'line', ], ], - 'chart' => [ - 'type' => 'line', - 'height' => 300, - ], 'stroke' => [ 'width' => [0, 4], ], - 'labels' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + 'xaxis' => [ + 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'legend' => [ + 'labels' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], ]; } } diff --git a/examples/Pie/BasicPieChart.php b/examples/Pie/BasicPieChart.php index 6701925..aa95c1b 100644 --- a/examples/Pie/BasicPieChart.php +++ b/examples/Pie/BasicPieChart.php @@ -35,6 +35,12 @@ protected function getOptions(): array ], 'series' => [2, 4, 6, 10, 14], 'labels' => ['Jan', 'Feb', 'Mar', 'Apr', 'May'], + 'legend' => [ + 'labels' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], ]; } } diff --git a/examples/Pie/DonutChart.php b/examples/Pie/DonutChart.php index 16d23bf..9e6ecd5 100644 --- a/examples/Pie/DonutChart.php +++ b/examples/Pie/DonutChart.php @@ -35,6 +35,12 @@ protected function getOptions(): array ], 'series' => [2, 4, 6, 10, 14], 'labels' => ['Jan', 'Feb', 'Mar', 'Apr', 'May'], + 'legend' => [ + 'labels' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], ]; } } diff --git a/examples/PolarArea/BasicPolarAreaChart.php b/examples/PolarArea/BasicPolarAreaChart.php index 9b1beb1..ba40111 100644 --- a/examples/PolarArea/BasicPolarAreaChart.php +++ b/examples/PolarArea/BasicPolarAreaChart.php @@ -35,6 +35,23 @@ protected function getOptions(): array ], 'series' => [2, 4, 6, 10, 14], 'labels' => ['Jan', 'Feb', 'Mar', 'Apr', 'May'], + 'legend' => [ + 'labels' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + 'dataLabels' => [ + 'enabled' => true, + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], ]; } } diff --git a/examples/Radar/BasicRadarChart.php b/examples/Radar/BasicRadarChart.php index fb98c9d..3d57c55 100644 --- a/examples/Radar/BasicRadarChart.php +++ b/examples/Radar/BasicRadarChart.php @@ -41,6 +41,20 @@ protected function getOptions(): array ], 'xaxis' => [ 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], ], 'colors' => ['#6366f1'], ]; diff --git a/examples/Radialbar/BasicRadialBarChart.php b/examples/Radialbar/BasicRadialBarChart.php new file mode 100644 index 0000000..7424fe2 --- /dev/null +++ b/examples/Radialbar/BasicRadialBarChart.php @@ -0,0 +1,66 @@ + [ + 'type' => 'radialBar', + 'height' => 300, + ], + 'series' => [75], + 'plotOptions' => [ + 'radialBar' => [ + 'hollow' => [ + 'size' => '70%', + ], + 'dataLabels' => [ + 'show' => true, + 'name' => [ + 'show' => true, + 'color' => '#9ca3af', + 'fontWeight' => 600, + ], + 'value' => [ + 'show' => true, + 'color' => '#9ca3af', + 'fontWeight' => 600, + 'fontSize' => '20px', + ], + ], + + ], + ], + 'stroke' => [ + 'lineCap' => 'round', + ], + 'labels' => ['Percent'], + 'colors' => ['#6366f1'], + ]; + } +} diff --git a/examples/RangeArea/BasicRangeAreaChart.php b/examples/RangeArea/BasicRangeAreaChart.php new file mode 100644 index 0000000..d9914fa --- /dev/null +++ b/examples/RangeArea/BasicRangeAreaChart.php @@ -0,0 +1,80 @@ + [ + 'type' => 'rangeArea', + 'height' => 300, + ], + 'series' => [ + [ + 'name' => 'BasicRangeAreaChart', + 'data' => [ + ['x' => 'Jan', 'y' => [0, 0]], + ['x' => 'Feb', 'y' => [3, 25]], + ['x' => 'Mar', 'y' => [5, 30]], + ['x' => 'Apr', 'y' => [4, 45]], + ['x' => 'May', 'y' => [10, 40]], + ['x' => 'Jun', 'y' => [11, 40]], + ['x' => 'Jul', 'y' => [20, 55]], + ['x' => 'Aug', 'y' => [15, 60]], + ['x' => 'Sep', 'y' => [8, 40]], + ['x' => 'Oct', 'y' => [7, 30]], + ['x' => 'Nov', 'y' => [3, 25]], + ['x' => 'Dec', 'y' => [0, 0]], + ], + ], + ], + 'xaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'colors' => ['#6366f1'], + 'stroke' => [ + 'curve' => 'smooth', + ], + 'dataLabels' => [ + 'enabled' => false, + ], + ]; + } +} diff --git a/examples/Scatter/BasicScatterChart.php b/examples/Scatter/BasicScatterChart.php new file mode 100644 index 0000000..d258ec3 --- /dev/null +++ b/examples/Scatter/BasicScatterChart.php @@ -0,0 +1,76 @@ + [ + 'type' => 'scatter', + 'height' => 300, + ], + 'series' => [ + [ + 'name' => 'Jan', + 'data' => [[16.4, 5.4], [21.7, 2], [25.4, 3], [19, 2], [10.9, 1], [13.6, 3.2], [10.9, 7.4], [10.9, 0], [10.9, 8.2], [16.4, 0], [16.4, 1.8], [13.6, 0.3], [13.6, 0], [29.9, 0], [27.1, 2.3], [16.4, 0], [13.6, 3.7], [10.9, 5.2], [16.4, 6.5], [10.9, 0], [24.5, 7.1], [10.9, 0], [8.1, 4.7], [19, 0], [21.7, 1.8], [27.1, 0], [24.5, 0], [27.1, 0], [29.9, 1.5], [27.1, 0.8], [22.1, 2]], + ], + [ + 'name' => 'Feb', + 'data' => [[36.4, 13.4], [1.7, 11], [5.4, 8], [9, 17], [1.9, 4], [3.6, 12.2], [1.9, 14.4], [1.9, 9], [1.9, 13.2], [1.4, 7], [6.4, 8.8], [3.6, 4.3], [1.6, 10], [9.9, 2], [7.1, 15], [1.4, 0], [3.6, 13.7], [1.9, 15.2], [6.4, 16.5], [0.9, 10], [4.5, 17.1], [10.9, 10], [0.1, 14.7], [9, 10], [12.7, 11.8], [2.1, 10], [2.5, 10], [27.1, 10], [2.9, 11.5], [7.1, 10.8], [2.1, 12]], + ], + [ + 'name' => 'Mar', + 'data' => [[21.7, 3], [23.6, 3.5], [24.6, 3], [29.9, 3], [21.7, 20], [23, 2], [10.9, 3], [28, 4], [27.1, 0.3], [16.4, 4], [13.6, 0], [19, 5], [22.4, 3], [24.5, 3], [32.6, 3], [27.1, 4], [29.6, 6], [31.6, 8], [21.6, 5], [20.9, 4], [22.4, 0], [32.6, 10.3], [29.7, 20.8], [24.5, 0.8], [21.4, 0], [21.7, 6.9], [28.6, 7.7], [15.4, 0], [18.1, 0], [33.4, 0], [16.4, 0]], + ], + ], + 'xaxis' => [ + 'tickAmount' => 7, + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'tickAmount' => 7, + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'legend' => [ + 'labels' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ]; + } +} diff --git a/examples/TimelineRangeBars/BasicTimelineRangeBarsChart.php b/examples/TimelineRangeBars/BasicTimelineRangeBarsChart.php new file mode 100644 index 0000000..87d8f7e --- /dev/null +++ b/examples/TimelineRangeBars/BasicTimelineRangeBarsChart.php @@ -0,0 +1,73 @@ + [ + 'type' => 'rangeBar', + 'height' => 300, + ], + 'series' => [ + [ + 'data' => [ + ['x' => 'Code', 'y' => [1, 3]], + ['x' => 'Test', 'y' => [3, 5]], + ['x' => 'Validation', 'y' => [5, 8]], + ['x' => 'Deployment', 'y' => [8, 12]], + ], + ], + ], + 'xaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + + ], + ], + 'colors' => ['#6366f1'], + 'plotOptions' => [ + 'bar' => [ + 'borderRadius' => 3, + 'horizontal' => true, + ], + ], + ]; + } +} diff --git a/examples/Treemap/BasicTreemapChart.php b/examples/Treemap/BasicTreemapChart.php new file mode 100644 index 0000000..c03f567 --- /dev/null +++ b/examples/Treemap/BasicTreemapChart.php @@ -0,0 +1,52 @@ + [ + 'type' => 'treemap', + 'height' => 300, + ], + 'series' => [ + [ + 'data' => [ + ['x' => 'Code', 'y' => 40], + ['x' => 'Test', 'y' => 20], + ['x' => 'Validation', 'y' => 60], + ['x' => 'Deployment', 'y' => 10], + ], + ], + ], + 'colors' => ['#6366f1'], + 'legend' => [ + 'show' => false, + ], + ]; + } +} From 6a2c105b986c0766658a659f325457b388cb1f9d Mon Sep 17 00:00:00 2001 From: Leandro Costa Ferreira Date: Wed, 7 Dec 2022 15:39:02 -0300 Subject: [PATCH 4/9] new chart commands --- src/Commands/FilamentApexChartsCommand.php | 96 ++++++++++++++++------ 1 file changed, 69 insertions(+), 27 deletions(-) diff --git a/src/Commands/FilamentApexChartsCommand.php b/src/Commands/FilamentApexChartsCommand.php index 9a02e46..5af8f6f 100644 --- a/src/Commands/FilamentApexChartsCommand.php +++ b/src/Commands/FilamentApexChartsCommand.php @@ -13,53 +13,90 @@ class FilamentApexChartsCommand extends Command use CanManipulateFiles; use CanValidateInput; + /** + * Signature + * + * @var string + */ public $signature = 'make:filament-apex-charts {name?}'; + /** + * Description + * + * @var string + */ public $description = 'Creates a Filament Apex Chart Widget class.'; - private $widget; + /** + * Filesystem instance + * + * @var Filesystem + */ + protected Filesystem $files; + + /** + * Widget + * + * @var string + */ + private string $widget; + + /** + * Chart Type + * + * @var string + */ + private string $chartType; + + /** + * Chart options + * + * @var array + */ + private array $chartOptions; + + /** + * Create a new command instance. + * + * @param Filesystem $files + */ + public function __construct(Filesystem $files) + { + parent::__construct(); + + $this->files = $files; + $this->chartOptions = config('filament-apex-charts.chart_options'); + } public function handle(): int { + //widget $this->widget = (string) Str::of($this->argument('name') ?? $this->askRequired('Name (e.g. `BlogPostsChart`)', 'name')) ->trim('/') ->trim('\\') ->trim(' ') ->replace('/', '\\'); + //chartType + $this->chartType = $this->choice( + 'Chart type', $this->chartOptions, + ); + $path = $this->getSourceFilePath(); $this->makeDirectory(dirname($path)); $contents = $this->getSourceFile(); - if (! $this->files->exists($path)) { - $this->files->put($path, $contents); - $this->info("Successfully created {$this->widget}!"); - } else { - $this->info("File : {$path} already exits"); + if ($this->files->exists($path)) { + $this->error("File : {$path} already exits!"); + exit(); } - return self::SUCCESS; - } - - /** - * Filesystem instance - * - * @var Filesystem - */ - protected $files; - - /** - * Create a new command instance. - * - * @param Filesystem $files - */ - public function __construct(Filesystem $files) - { - parent::__construct(); + $this->files->put($path, $contents); + $this->info("Successfully created {$this->widget}! Check out your new widget on the dashboard page."); - $this->files = $files; + return self::SUCCESS; } /** @@ -69,7 +106,12 @@ public function __construct(Filesystem $files) */ public function getStubPath() { - return str_replace('src\Commands', '', __DIR__).'stubs\Widget.stub'; + $path = Str::of(__DIR__) + ->replace('src\Commands', 'stubs\\') + ->append($this->chartType) + ->append('.stub'); + + return $path; } /** @@ -109,7 +151,7 @@ public function getStubContents($stub, $stubVariables = []) $contents = file_get_contents($stub); foreach ($stubVariables as $search => $replace) { - $contents = str_replace('$'.$search.'$', $replace, $contents); + $contents = Str::of($contents)->replace('$'.$search.'$', $replace); } return $contents; From c9f528f02fbae014e829e1295d88e6ca5272cfd1 Mon Sep 17 00:00:00 2001 From: Leandro Costa Ferreira Date: Wed, 7 Dec 2022 15:39:52 -0300 Subject: [PATCH 5/9] show message to empty chart --- resources/views/widgets/apex-chart-widget.blade.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/views/widgets/apex-chart-widget.blade.php b/resources/views/widgets/apex-chart-widget.blade.php index 7c8dd01..bc1aee9 100644 --- a/resources/views/widgets/apex-chart-widget.blade.php +++ b/resources/views/widgets/apex-chart-widget.blade.php @@ -37,6 +37,8 @@ "wire:poll.{$pollingInterval}=\"updateChartOptions\"" : '' !!}> + + @if(count($this->getOptions()) >0)
+ @else +

No chart data available.

+ @endif From f9bf778935f0340ff9e42c92f12bd70c154c30ea Mon Sep 17 00:00:00 2001 From: Leandro Costa Ferreira Date: Wed, 7 Dec 2022 15:40:20 -0300 Subject: [PATCH 6/9] new chart stubs --- stubs/Area.stub | 68 ++++++++++++++++++++++++++ stubs/Bar.stub | 68 ++++++++++++++++++++++++++ stubs/Boxplot.stub | 74 ++++++++++++++++++++++++++++ stubs/Bubble.stub | 72 ++++++++++++++++++++++++++++ stubs/Candlestick.stub | 66 +++++++++++++++++++++++++ stubs/Column.stub | 62 ++++++++++++++++++++++++ stubs/{Widget.stub => Donut.stub} | 16 +++---- stubs/Empty.stub | 35 ++++++++++++++ stubs/Heatmap.stub | 66 +++++++++++++++++++++++++ stubs/Line.stub | 65 +++++++++++++++++++++++++ stubs/Mixed-LineAndColumn.stub | 76 +++++++++++++++++++++++++++++ stubs/Pie.stub | 46 ++++++++++++++++++ stubs/PolarArea.stub | 57 ++++++++++++++++++++++ stubs/Radar.stub | 62 ++++++++++++++++++++++++ stubs/Radialbar.stub | 66 +++++++++++++++++++++++++ stubs/RangeArea.stub | 80 +++++++++++++++++++++++++++++++ stubs/Scatter.stub | 76 +++++++++++++++++++++++++++++ stubs/TimelineRangeBars.stub | 73 ++++++++++++++++++++++++++++ stubs/Treemap.stub | 52 ++++++++++++++++++++ 19 files changed, 1172 insertions(+), 8 deletions(-) create mode 100644 stubs/Area.stub create mode 100644 stubs/Bar.stub create mode 100644 stubs/Boxplot.stub create mode 100644 stubs/Bubble.stub create mode 100644 stubs/Candlestick.stub create mode 100644 stubs/Column.stub rename stubs/{Widget.stub => Donut.stub} (65%) create mode 100644 stubs/Empty.stub create mode 100644 stubs/Heatmap.stub create mode 100644 stubs/Line.stub create mode 100644 stubs/Mixed-LineAndColumn.stub create mode 100644 stubs/Pie.stub create mode 100644 stubs/PolarArea.stub create mode 100644 stubs/Radar.stub create mode 100644 stubs/Radialbar.stub create mode 100644 stubs/RangeArea.stub create mode 100644 stubs/Scatter.stub create mode 100644 stubs/TimelineRangeBars.stub create mode 100644 stubs/Treemap.stub diff --git a/stubs/Area.stub b/stubs/Area.stub new file mode 100644 index 0000000..7dd72f8 --- /dev/null +++ b/stubs/Area.stub @@ -0,0 +1,68 @@ + [ + 'type' => 'area', + 'height' => 300, + ], + 'series' => [ + [ + 'name' => '$CLASS_NAME$', + 'data' => [7, 4, 6, 10, 14, 7, 5, 9, 10, 15, 13, 18], + ], + ], + 'xaxis' => [ + 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'colors' => ['#6366f1'], + 'stroke' => [ + 'curve' => 'smooth', + ], + 'dataLabels' => [ + 'enabled' => false, + ], + ]; + } +} diff --git a/stubs/Bar.stub b/stubs/Bar.stub new file mode 100644 index 0000000..5912121 --- /dev/null +++ b/stubs/Bar.stub @@ -0,0 +1,68 @@ + [ + 'type' => 'bar', + 'height' => 300, + ], + 'series' => [ + [ + 'name' => 'BasicBarChart', + 'data' => [7, 10, 13, 15, 18], + ], + ], + 'xaxis' => [ + 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'colors' => ['#6366f1'], + 'plotOptions' => [ + 'bar' => [ + 'borderRadius' => 3, + 'horizontal' => true, + ], + ], + ]; + } +} diff --git a/stubs/Boxplot.stub b/stubs/Boxplot.stub new file mode 100644 index 0000000..21d06e3 --- /dev/null +++ b/stubs/Boxplot.stub @@ -0,0 +1,74 @@ + [ + 'type' => 'boxPlot', + 'height' => 300, + ], + 'series' => [ + [ + 'type' => 'boxPlot', + 'data' => [ + ['x' => 'Jan', 'y' => [54, 66, 69, 75, 88]], + ['x' => 'Fev', 'y' => [43, 65, 69, 76, 81]], + ['x' => 'Mar', 'y' => [31, 39, 45, 51, 59]], + ['x' => 'Apr', 'y' => [39, 46, 55, 65, 71]], + ['x' => 'May', 'y' => [29, 31, 35, 39, 44]], + ], + ], + ], + 'xaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'plotOptions' => [ + 'boxPlot' => [ + 'colors' => [ + 'upper' => '#6366f1', + 'lower' => '#84cc16', + ], + ], + ], + ]; + } +} diff --git a/stubs/Bubble.stub b/stubs/Bubble.stub new file mode 100644 index 0000000..af7adc4 --- /dev/null +++ b/stubs/Bubble.stub @@ -0,0 +1,72 @@ + [ + 'type' => 'bubble', + 'height' => 300, + ], + 'series' => [ + ['name' => 'Jan', 'data' => [[49, 12, 10], [24, 31, 10], [54, 20, 14], [52, 25, 67], [13, 69, 53], [55, 61, 55], [13, 70, 41], [45, 56, 61], [60, 21, 23], [48, 30, 69]]], + ['name' => 'Feb', 'data' => [[70, 53, 16], [39, 33, 53], [14, 55, 51], [44, 28, 32], [26, 46, 33], [61, 56, 11], [11, 29, 29], [19, 64, 67], [26, 19, 28], [28, 69, 44]]], + ['name' => 'Mar', 'data' => [[63, 62, 50], [12, 37, 12], [30, 35, 25], [29, 16, 35], [67, 34, 36], [67, 19, 23], [21, 44, 48], [14, 50, 60], [61, 63, 51], [19, 33, 22]]], + ['name' => 'Apr', 'data' => [[22, 14, 29], [57, 12, 63], [65, 63, 61], [56, 27, 44], [61, 54, 41], [43, 69, 12], [65, 68, 42], [56, 33, 42], [46, 48, 12], [54, 56, 12]]], + ['name' => 'May', 'data' => [[57, 68, 50], [22, 37, 32], [33, 46, 18], [51, 14, 39], [23, 63, 60], [65, 24, 38], [67, 33, 59], [19, 62, 24], [19, 55, 24], [12, 20, 32]]], + ], + 'xaxis' => [ + 'min' => 5, + 'max' => 80, + 'type' => 'category', + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'min' => 5, + 'max' => 80, + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'fill' => [ + 'opacity' => 0.7, + ], + 'dataLabels' => [ + 'enabled' => false, + ], + ]; + } +} diff --git a/stubs/Candlestick.stub b/stubs/Candlestick.stub new file mode 100644 index 0000000..fa07f44 --- /dev/null +++ b/stubs/Candlestick.stub @@ -0,0 +1,66 @@ + [ + 'type' => 'candlestick', + 'height' => 300, + ], + 'series' => [ + [ + 'type' => 'candlestick', + 'data' => [ + ['x' => 'Jan', 'y' => [6629.81, 6650.5, 6623.04, 6633.33]], + ['x' => 'Fev', 'y' => [6632.01, 6643.59, 6620, 6630.11]], + ['x' => 'Mar', 'y' => [6630.71, 6648.95, 6623.34, 6635.65]], + ['x' => 'Apr', 'y' => [6635.65, 6651, 6629.67, 6638.24]], + ['x' => 'May', 'y' => [6638.24, 6640, 6620, 6624.47]], + ], + ], + ], + 'xaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + ]; + } +} diff --git a/stubs/Column.stub b/stubs/Column.stub new file mode 100644 index 0000000..eeb2943 --- /dev/null +++ b/stubs/Column.stub @@ -0,0 +1,62 @@ + [ + 'type' => 'bar', + 'height' => 300, + ], + 'series' => [ + [ + 'name' => '$CLASS_NAME$', + 'data' => [7, 4, 6, 10, 14, 7, 5, 9, 10, 15, 13, 18], + ], + ], + 'xaxis' => [ + 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'colors' => ['#6366f1'], + ]; + } +} diff --git a/stubs/Widget.stub b/stubs/Donut.stub similarity index 65% rename from stubs/Widget.stub rename to stubs/Donut.stub index 23180d2..15116c5 100644 --- a/stubs/Widget.stub +++ b/stubs/Donut.stub @@ -30,17 +30,17 @@ class $CLASS_NAME$ extends ApexChartWidget { return [ 'chart' => [ - 'type' => 'bar' + 'type' => 'donut', + 'height' => 300, ], - 'series' => [ - [ - 'name' => '$CLASS_NAME$', - 'data' => [90, 80, 70, 60, 50, 40, 40, 50, 60, 70, 80, 90] + 'series' => [2, 4, 6, 10, 14], + 'labels' => ['Jan', 'Feb', 'Mar', 'Apr', 'May'], + 'legend' => [ + 'labels' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, ], ], - 'xaxis' => [ - 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] - ], ]; } } diff --git a/stubs/Empty.stub b/stubs/Empty.stub new file mode 100644 index 0000000..7e99244 --- /dev/null +++ b/stubs/Empty.stub @@ -0,0 +1,35 @@ + [ + 'type' => 'heatmap', + 'height' => 300, + ], + 'series' => [ + ['name' => 'Jan', 'data' => [[55, 70], [33, 42], [68, 40], [40, 48], [63, 19], [38, 23]]], + ['name' => 'Feb', 'data' => [[44, 38], [37, 47], [16, 52], [30, 27], [46, 55], [37, 13]]], + ['name' => 'Mar', 'data' => [[10, 42], [30, 16], [54, 34], [31, 47], [30, 31], [58, 60]]], + ['name' => 'Apr', 'data' => [[14, 60], [50, 30], [64, 13], [34, 32], [41, 23], [15, 70]]], + ['name' => 'May', 'data' => [[66, 69], [42, 20], [47, 34], [12, 37], [59, 29], [25, 60]]], + ], + 'xaxis' => [ + 'type' => 'category', + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'dataLabels' => [ + 'enabled' => false, + ], + 'colors' => ['#6366f1'], + ]; + } +} diff --git a/stubs/Line.stub b/stubs/Line.stub new file mode 100644 index 0000000..df45b5d --- /dev/null +++ b/stubs/Line.stub @@ -0,0 +1,65 @@ + [ + 'type' => 'line', + 'height' => 300, + ], + 'series' => [ + [ + 'name' => '$CLASS_NAME$', + 'data' => [2, 4, 6, 10, 14, 7, 2, 9, 10, 15, 13, 18], + ], + ], + 'xaxis' => [ + 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'colors' => ['#6366f1'], + 'stroke' => [ + 'curve' => 'smooth', + ], + ]; + } +} diff --git a/stubs/Mixed-LineAndColumn.stub b/stubs/Mixed-LineAndColumn.stub new file mode 100644 index 0000000..a65ed8a --- /dev/null +++ b/stubs/Mixed-LineAndColumn.stub @@ -0,0 +1,76 @@ + [ + 'type' => 'line', + 'height' => 300, + ], + 'series' => [ + [ + 'name' => 'Column', + 'data' => [20, 40, 60, 100, 140, 70, 20, 90, 100, 150, 130, 180], + 'type' => 'column', + ], + [ + 'name' => 'Line', + 'data' => [10, 20, 30, 50, 40, 70, 30, 10, 60, 80, 20, 18], + 'type' => 'line', + ], + ], + 'stroke' => [ + 'width' => [0, 4], + ], + 'xaxis' => [ + 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'legend' => [ + 'labels' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ]; + } +} diff --git a/stubs/Pie.stub b/stubs/Pie.stub new file mode 100644 index 0000000..c245e38 --- /dev/null +++ b/stubs/Pie.stub @@ -0,0 +1,46 @@ + [ + 'type' => 'pie', + 'height' => 300, + ], + 'series' => [2, 4, 6, 10, 14], + 'labels' => ['Jan', 'Feb', 'Mar', 'Apr', 'May'], + 'legend' => [ + 'labels' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ]; + } +} diff --git a/stubs/PolarArea.stub b/stubs/PolarArea.stub new file mode 100644 index 0000000..4e028a2 --- /dev/null +++ b/stubs/PolarArea.stub @@ -0,0 +1,57 @@ + [ + 'type' => 'polarArea', + 'height' => 300, + ], + 'series' => [2, 4, 6, 10, 14], + 'labels' => ['Jan', 'Feb', 'Mar', 'Apr', 'May'], + 'legend' => [ + 'labels' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + 'dataLabels' => [ + 'enabled' => true, + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + ]; + } +} diff --git a/stubs/Radar.stub b/stubs/Radar.stub new file mode 100644 index 0000000..704df62 --- /dev/null +++ b/stubs/Radar.stub @@ -0,0 +1,62 @@ + [ + 'type' => 'radar', + 'height' => 300, + ], + 'series' => [ + [ + 'name' => '$CLASS_NAME$', + 'data' => [2, 4, 6, 10, 14], + ], + ], + 'xaxis' => [ + 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'colors' => ['#6366f1'], + ]; + } +} diff --git a/stubs/Radialbar.stub b/stubs/Radialbar.stub new file mode 100644 index 0000000..86f77e0 --- /dev/null +++ b/stubs/Radialbar.stub @@ -0,0 +1,66 @@ + [ + 'type' => 'radialBar', + 'height' => 300, + ], + 'series' => [75], + 'plotOptions' => [ + 'radialBar' => [ + 'hollow' => [ + 'size' => '70%', + ], + 'dataLabels' => [ + 'show' => true, + 'name' => [ + 'show' => true, + 'color' => '#9ca3af', + 'fontWeight' => 600, + ], + 'value' => [ + 'show' => true, + 'color' => '#9ca3af', + 'fontWeight' => 600, + 'fontSize' => '20px', + ], + ], + + ], + ], + 'stroke' => [ + 'lineCap' => 'round', + ], + 'labels' => ['$CLASS_NAME$'], + 'colors' => ['#6366f1'], + ]; + } +} diff --git a/stubs/RangeArea.stub b/stubs/RangeArea.stub new file mode 100644 index 0000000..b54e7f0 --- /dev/null +++ b/stubs/RangeArea.stub @@ -0,0 +1,80 @@ + [ + 'type' => 'rangeArea', + 'height' => 300, + ], + 'series' => [ + [ + 'name' => '$CLASS_NAME$', + 'data' => [ + ['x' => 'Jan', 'y' => [0, 0]], + ['x' => 'Feb', 'y' => [3, 25]], + ['x' => 'Mar', 'y' => [5, 30]], + ['x' => 'Apr', 'y' => [4, 45]], + ['x' => 'May', 'y' => [10, 40]], + ['x' => 'Jun', 'y' => [11, 40]], + ['x' => 'Jul', 'y' => [20, 55]], + ['x' => 'Aug', 'y' => [15, 60]], + ['x' => 'Sep', 'y' => [8, 40]], + ['x' => 'Oct', 'y' => [7, 30]], + ['x' => 'Nov', 'y' => [3, 25]], + ['x' => 'Dec', 'y' => [0, 0]], + ], + ], + ], + 'xaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'colors' => ['#6366f1'], + 'stroke' => [ + 'curve' => 'smooth', + ], + 'dataLabels' => [ + 'enabled' => false, + ], + ]; + } +} diff --git a/stubs/Scatter.stub b/stubs/Scatter.stub new file mode 100644 index 0000000..506cf25 --- /dev/null +++ b/stubs/Scatter.stub @@ -0,0 +1,76 @@ + [ + 'type' => 'scatter', + 'height' => 300, + ], + 'series' => [ + [ + 'name' => 'Jan', + 'data' => [[16.4, 5.4], [21.7, 2], [25.4, 3], [19, 2], [10.9, 1], [13.6, 3.2], [10.9, 7.4], [10.9, 0], [10.9, 8.2], [16.4, 0], [16.4, 1.8], [13.6, 0.3], [13.6, 0], [29.9, 0], [27.1, 2.3], [16.4, 0], [13.6, 3.7], [10.9, 5.2], [16.4, 6.5], [10.9, 0], [24.5, 7.1], [10.9, 0], [8.1, 4.7], [19, 0], [21.7, 1.8], [27.1, 0], [24.5, 0], [27.1, 0], [29.9, 1.5], [27.1, 0.8], [22.1, 2]], + ], + [ + 'name' => 'Feb', + 'data' => [[36.4, 13.4], [1.7, 11], [5.4, 8], [9, 17], [1.9, 4], [3.6, 12.2], [1.9, 14.4], [1.9, 9], [1.9, 13.2], [1.4, 7], [6.4, 8.8], [3.6, 4.3], [1.6, 10], [9.9, 2], [7.1, 15], [1.4, 0], [3.6, 13.7], [1.9, 15.2], [6.4, 16.5], [0.9, 10], [4.5, 17.1], [10.9, 10], [0.1, 14.7], [9, 10], [12.7, 11.8], [2.1, 10], [2.5, 10], [27.1, 10], [2.9, 11.5], [7.1, 10.8], [2.1, 12]], + ], + [ + 'name' => 'Mar', + 'data' => [[21.7, 3], [23.6, 3.5], [24.6, 3], [29.9, 3], [21.7, 20], [23, 2], [10.9, 3], [28, 4], [27.1, 0.3], [16.4, 4], [13.6, 0], [19, 5], [22.4, 3], [24.5, 3], [32.6, 3], [27.1, 4], [29.6, 6], [31.6, 8], [21.6, 5], [20.9, 4], [22.4, 0], [32.6, 10.3], [29.7, 20.8], [24.5, 0.8], [21.4, 0], [21.7, 6.9], [28.6, 7.7], [15.4, 0], [18.1, 0], [33.4, 0], [16.4, 0]], + ], + ], + 'xaxis' => [ + 'tickAmount' => 7, + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'tickAmount' => 7, + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'legend' => [ + 'labels' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ]; + } +} diff --git a/stubs/TimelineRangeBars.stub b/stubs/TimelineRangeBars.stub new file mode 100644 index 0000000..128eb2e --- /dev/null +++ b/stubs/TimelineRangeBars.stub @@ -0,0 +1,73 @@ + [ + 'type' => 'rangeBar', + 'height' => 300, + ], + 'series' => [ + [ + 'data' => [ + ['x' => 'Code', 'y' => [1, 3]], + ['x' => 'Test', 'y' => [3, 5]], + ['x' => 'Validation', 'y' => [5, 8]], + ['x' => 'Deployment', 'y' => [8, 12]], + ], + ], + ], + 'xaxis' => [ + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + ], + ], + 'yaxis' => [ + 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May'], + 'labels' => [ + 'style' => [ + 'colors' => '#9ca3af', + 'fontWeight' => 600, + ], + + ], + ], + 'colors' => ['#6366f1'], + 'plotOptions' => [ + 'bar' => [ + 'borderRadius' => 3, + 'horizontal' => true, + ], + ], + ]; + } +} diff --git a/stubs/Treemap.stub b/stubs/Treemap.stub new file mode 100644 index 0000000..ea518ad --- /dev/null +++ b/stubs/Treemap.stub @@ -0,0 +1,52 @@ + [ + 'type' => 'treemap', + 'height' => 300, + ], + 'series' => [ + [ + 'data' => [ + ['x' => 'Code', 'y' => 40], + ['x' => 'Test', 'y' => 20], + ['x' => 'Validation', 'y' => 60], + ['x' => 'Deployment', 'y' => 10], + ], + ], + ], + 'colors' => ['#6366f1'], + 'legend' => [ + 'show' => false, + ], + ]; + } +} From 4e9a535dee8e1d049186596741ab0a265712e388 Mon Sep 17 00:00:00 2001 From: Leandro Costa Ferreira Date: Wed, 7 Dec 2022 15:40:36 -0300 Subject: [PATCH 7/9] removing database settings --- tests/TestCase.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 5335995..2c2867b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,7 +2,6 @@ namespace Leandrocfe\FilamentApexCharts\Tests; -use Illuminate\Database\Eloquent\Factories\Factory; use Leandrocfe\FilamentApexCharts\FilamentApexChartsServiceProvider; use Orchestra\Testbench\TestCase as Orchestra; @@ -11,10 +10,6 @@ class TestCase extends Orchestra protected function setUp(): void { parent::setUp(); - - Factory::guessFactoryNamesUsing( - fn (string $modelName) => 'Leandrocfe\\FilamentApexCharts\\Database\\Factories\\'.class_basename($modelName).'Factory' - ); } protected function getPackageProviders($app) @@ -26,11 +21,5 @@ protected function getPackageProviders($app) public function getEnvironmentSetUp($app) { - config()->set('database.default', 'testing'); - - /* - $migration = include __DIR__.'/../database/migrations/create_filament-apex-charts_table.php.stub'; - $migration->up(); - */ } } From 322732691e2c7b134ac22b35afe97e4a463b1287 Mon Sep 17 00:00:00 2001 From: Leandro Costa Ferreira Date: Wed, 7 Dec 2022 15:49:26 -0300 Subject: [PATCH 8/9] updated gradient example --- examples/Radialbar/GradientCircleChart.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/Radialbar/GradientCircleChart.php b/examples/Radialbar/GradientCircleChart.php index 978f5f8..9302d1b 100644 --- a/examples/Radialbar/GradientCircleChart.php +++ b/examples/Radialbar/GradientCircleChart.php @@ -36,7 +36,7 @@ protected function getOptions(): array 'show' => true, ], ], - 'series' => [rand(0, 100)], + 'series' => [75], 'plotOptions' => [ 'radialBar' => [ 'startAngle' => -135, @@ -72,13 +72,15 @@ protected function getOptions(): array 'dataLabels' => [ 'show' => true, 'name' => [ - 'offsetY' => -10, 'show' => true, - 'color' => '#888', + 'offsetY' => -10, + 'color' => '#9ca3af', + 'fontWeight' => 600, ], 'value' => [ - 'color' => '#111', 'show' => true, + 'color' => '#9ca3af', + 'fontWeight' => 600, ], ], From 3ff4bffc157528817b7c94e15754a06f34b577d9 Mon Sep 17 00:00:00 2001 From: Leandro Costa Ferreira Date: Wed, 7 Dec 2022 16:12:36 -0300 Subject: [PATCH 9/9] 0.1.1 --- CHANGELOG.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6297c02..2c62bb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,28 @@ -# Changelog +# Change Log -All notable changes to `filament-apex-charts` will be documented in this file. +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +## 0.1.1 + +### Added + +- New commands with available chart samples. +- New chart examples. +- Documentation. + +### Changed + +- Documentation and chart examples. + +### Fixed + +- Show the message **No chart data available** when the chart option is empty. + +## 0.1.0 + +### Added + +- Initial commit.