Skip to content

Commit

Permalink
Merge pull request #3 from daredloco/nightly
Browse files Browse the repository at this point in the history
Fixed Waterfall Charts
  • Loading branch information
daredloco authored Dec 7, 2022
2 parents 0505e83 + 894488f commit cf8c360
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ composer require helvetiapps/lagoon-charts
* Column Charts
* Line Charts
* Pie Charts
* Waterfall Charts
* Gantt Charts (Preview)


Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/DataTables/WaterfallChartTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Livewire/WaterfallChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Carbon\Carbon;
use Livewire\Component;

class CandlestickChart extends Component
class WaterfallChart extends Component
{
public $title = "NO_TITLE";
public $chartData = [];
Expand Down
2 changes: 2 additions & 0 deletions src/LagoonServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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())
{
Expand Down

0 comments on commit cf8c360

Please sign in to comment.