diff --git a/README.md b/README.md index 73c05c4..89699d8 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ composer require helvetiapps/lagoon-charts * Column Charts * Line Charts * Pie Charts +* Waterfall Charts * Gantt Charts (Preview) @@ -87,6 +88,22 @@ Blade ``` +### Waterfall Chart + +Livewire +```php +$waterfallChartTable = new \HelvetiApps\LagoonCharts\DataTables\WaterfallChartTable(); +$waterfallChartTable->addRow("Mon", 100, 200); +$waterfallChartTable->addRow("Tue", 200, 300); +$data = $waterfallChartTable->toArray(); +``` + +Blade +``` +@livewire('lagoon-waterfall-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => []], key('uniquekey'.now())) +``` + + ### Bar Chart Livewire diff --git a/src/DataTables/WaterfallChartTable.php b/src/DataTables/WaterfallChartTable.php index 536b6a1..ae7e55b 100644 --- a/src/DataTables/WaterfallChartTable.php +++ b/src/DataTables/WaterfallChartTable.php @@ -19,11 +19,14 @@ public function __construct(array $rows = []) if(count($row) != $this->colCount){ throw new Exception("Row ".$rowCount." has ".count($row)." columns but needs to have ".$this->colCount."!"); } - array_push($this->data, $row); + array_push($this->data, $rows); } } public function addRow(string $label, $min, $max){ + if($min > $max){ + throw new Exception("The minimum valueu is bigger than the maximum value!"); + } array_push($this->data, [$label, $min, $min, $max, $max]); } diff --git a/src/Http/Livewire/WaterfallChart.php b/src/Http/Livewire/WaterfallChart.php index b557686..fe88cfe 100644 --- a/src/Http/Livewire/WaterfallChart.php +++ b/src/Http/Livewire/WaterfallChart.php @@ -5,7 +5,7 @@ use Carbon\Carbon; use Livewire\Component; -class CandlestickChart extends Component +class WaterfallChart extends Component { public $title = "NO_TITLE"; public $chartData = []; diff --git a/src/LagoonServiceProvider.php b/src/LagoonServiceProvider.php index ac3eded..67a152a 100644 --- a/src/LagoonServiceProvider.php +++ b/src/LagoonServiceProvider.php @@ -9,6 +9,7 @@ use Helvetiapps\LagoonCharts\Http\Livewire\CandlestickChart; use Helvetiapps\LagoonCharts\Http\Livewire\ColumnChart; use Helvetiapps\LagoonCharts\Http\Livewire\GanttChart; +use Helvetiapps\LagoonCharts\Http\Livewire\WaterfallChart; use Illuminate\Support\ServiceProvider; use Livewire\Livewire; @@ -29,6 +30,7 @@ public function boot() Livewire::component('lagoon-gantt-chart', GanttChart::class); Livewire::component('lagoon-gantt-chart', ColumnChart::class); Livewire::component('lagoon-candlestick-chart', CandlestickChart::class); + Livewire::component('lagoon-waterfall-chart', WaterfallChart::class); if ($this->app->runningInConsole()) {