From 6da3c0fe10c93d1c9205bf0705d0ce5a03940784 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 11:22:25 -0300
Subject: [PATCH 01/38] Update composer.json
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 0049e5a..55e1e22 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "helvetiapps/lagoon-charts",
"description": "Google Charts for Laravel Livewire",
"type": "library",
- "license": "proprietary",
+ "license": "GPL-3.0",
"autoload": {
"psr-4": {
"Helvetiapps\\LagoonCharts\\": "src/"
From b6dea565f2aac7ca32262c5b4b40dce99a25c5d5 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 11:24:17 -0300
Subject: [PATCH 02/38] Update README.md
---
README.md | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index 3e799b7..da34628 100644
--- a/README.md
+++ b/README.md
@@ -12,17 +12,9 @@ Google Charts for Laravel Livewire
## Installation
-Add to composer.json
+Run composer:
```
-"require": {
- "helvetiapps/lagoon-charts": "^0.1"
-},
-"repositories": [
- {
- "url": "https://github.com/daredloco/lagoon-charts.git",
- "type": "git"
- }
-]
+composer require helvetiapps/lagoon-charts
```
From 8db0cd64c6862abc300408642c1b31b8c4891afa Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 11:42:24 -0300
Subject: [PATCH 03/38] Added GanttChart
---
.../views/livewire/gantt-chart.blade.php | 42 +++++++++++++++
src/DataTables/GanttChartTable.php | 31 +++++++++++
src/Http/Livewire/GanttChart.php | 51 +++++++++++++++++++
src/LagoonServiceProvider.php | 2 +
4 files changed, 126 insertions(+)
create mode 100644 resources/views/livewire/gantt-chart.blade.php
create mode 100644 src/DataTables/GanttChartTable.php
create mode 100644 src/Http/Livewire/GanttChart.php
diff --git a/resources/views/livewire/gantt-chart.blade.php b/resources/views/livewire/gantt-chart.blade.php
new file mode 100644
index 0000000..36faf26
--- /dev/null
+++ b/resources/views/livewire/gantt-chart.blade.php
@@ -0,0 +1,42 @@
+
+ @once
+ @push('styles')
+
+ @endpush
+ @push('headerScripts')
+
+
+ @endpush
+ @endonce
+
+
+
+
+
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
new file mode 100644
index 0000000..16a34e8
--- /dev/null
+++ b/src/DataTables/GanttChartTable.php
@@ -0,0 +1,31 @@
+year."','".$start->month."','".$start->day."')",
+ "new Date('".$end->year."','".$end->month."','".$end->day."')",
+ $duration,
+ $completion,
+ $dependencies
+ ]);
+ }
+
+ public function __toString()
+ {
+ return json_encode($this->data);
+ }
+
+ public function toArray():array{
+ return $this->data;
+ }
+
+}
\ No newline at end of file
diff --git a/src/Http/Livewire/GanttChart.php b/src/Http/Livewire/GanttChart.php
new file mode 100644
index 0000000..186b2ba
--- /dev/null
+++ b/src/Http/Livewire/GanttChart.php
@@ -0,0 +1,51 @@
+ $this->title,
+ ];
+
+ if(!is_null($this->height)){
+ $newOptions["height"] = $this->height;
+ }
+ if(!is_null($this->width)){
+ $newOptions["width"] = $this->width;
+ }
+ if(!is_null($this->options) && is_array($this->options)){
+ foreach($this->options as $key => $value){
+ $newOptions[$key] = $value;
+ }
+ }
+
+ $this->optionsArray = $newOptions;
+ }
+
+ public function render()
+ {
+ $this->random = Carbon::now()->timestamp;
+ return view('lagoon::livewire.area-chart');
+ }
+}
diff --git a/src/LagoonServiceProvider.php b/src/LagoonServiceProvider.php
index 59ff923..6811831 100644
--- a/src/LagoonServiceProvider.php
+++ b/src/LagoonServiceProvider.php
@@ -6,6 +6,7 @@
use Helvetiapps\LagoonCharts\Http\Livewire\PieChart;
use Helvetiapps\LagoonCharts\Http\Livewire\AreaChart;
use Helvetiapps\LagoonCharts\Http\Livewire\BarChart;
+use Helvetiapps\LagoonCharts\Http\Livewire\GanttChart;
use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;
@@ -23,6 +24,7 @@ public function boot()
Livewire::component('lagoon-pie-chart', PieChart::class);
Livewire::component('lagoon-area-chart', AreaChart::class);
Livewire::component('lagoon-bar-chart', BarChart::class);
+ Livewire::component('lagoon-gantt-chart', GanttChart::class);
if ($this->app->runningInConsole())
{
From 76408bc3e6d37fdc28fb830dc91d72b4a5858354 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 11:59:07 -0300
Subject: [PATCH 04/38] Added duration calculation to miliseconds
---
src/DataTables/GanttChartTable.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index 16a34e8..9be9cc6 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -7,13 +7,13 @@
class GanttChartTable{
private $data = [];
- public function addTask(string $id, string $name, Carbon $start, Carbon $end, int $duration, int $completion, string $dependencies){
+ public function addTask(string $id, string $name, Carbon $start, Carbon $end, int $duration, int $completion, ?string $dependencies){
array_push($data, [
$id,
$name,
"new Date('".$start->year."','".$start->month."','".$start->day."')",
"new Date('".$end->year."','".$end->month."','".$end->day."')",
- $duration,
+ $duration * 24 * 60 * 60 * 1000,
$completion,
$dependencies
]);
From ba4e18d623c2cd7f134407fd4cd74257e39aa84a Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 12:02:20 -0300
Subject: [PATCH 05/38] Fixed exception in GanttChartTable
---
src/DataTables/GanttChartTable.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index 9be9cc6..198665b 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -8,7 +8,7 @@ class GanttChartTable{
private $data = [];
public function addTask(string $id, string $name, Carbon $start, Carbon $end, int $duration, int $completion, ?string $dependencies){
- array_push($data, [
+ array_push($this->data, [
$id,
$name,
"new Date('".$start->year."','".$start->month."','".$start->day."')",
From 96752686d00f4a5fd08008adc5a8b26b8a9c7c8e Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 12:07:46 -0300
Subject: [PATCH 06/38] Possible fix for GanttChartTable
---
src/DataTables/GanttChartTable.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index 198665b..b9f0b5c 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -11,8 +11,8 @@ public function addTask(string $id, string $name, Carbon $start, Carbon $end, in
array_push($this->data, [
$id,
$name,
- "new Date('".$start->year."','".$start->month."','".$start->day."')",
- "new Date('".$end->year."','".$end->month."','".$end->day."')",
+ $start->format('Y-m-d'),
+ $end->format('Y-m-d'),
$duration * 24 * 60 * 60 * 1000,
$completion,
$dependencies
From 3952ebfbafb4e408b49294354d19fdbcb9f5c835 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 12:11:37 -0300
Subject: [PATCH 07/38] Fix for exception in GanttChart
---
src/Http/Livewire/GanttChart.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Http/Livewire/GanttChart.php b/src/Http/Livewire/GanttChart.php
index 186b2ba..7da3ef7 100644
--- a/src/Http/Livewire/GanttChart.php
+++ b/src/Http/Livewire/GanttChart.php
@@ -46,6 +46,6 @@ public function mount(){
public function render()
{
$this->random = Carbon::now()->timestamp;
- return view('lagoon::livewire.area-chart');
+ return view('lagoon::livewire.gantt-chart');
}
}
From 3f31721e66173da5a75aab10e8a2522ee28891f7 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 12:13:45 -0300
Subject: [PATCH 08/38] Fixed exception in GanttChart
---
resources/views/livewire/gantt-chart.blade.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/resources/views/livewire/gantt-chart.blade.php b/resources/views/livewire/gantt-chart.blade.php
index 36faf26..8307ce8 100644
--- a/resources/views/livewire/gantt-chart.blade.php
+++ b/resources/views/livewire/gantt-chart.blade.php
@@ -17,7 +17,7 @@
google.charts.setOnLoadCallback(drawChart{{ $chartId }});
function drawChart{{ $chartId }}() {
- var data = google.visualization.DataTable();
+ var data = new google.visualization.DataTable();
data.addColumn('string', 'Task ID');
data.addColumn('string', 'Task Name');
@@ -29,7 +29,7 @@ function drawChart{{ $chartId }}() {
data.addColumn('string', 'Dependencies');
data.addRows(@json($chartData));
-
+
var options = @json($optionsArray);
var chart = new google.visualization.Gantt(document.getElementById('{{ $chartId.$random }}'));
From 173e04bf4b027bcd558b6633c4d97b391bcb079c Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 12:18:01 -0300
Subject: [PATCH 09/38] Update GanttChartTable.php
---
src/DataTables/GanttChartTable.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index b9f0b5c..9e35abf 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -11,6 +11,7 @@ public function addTask(string $id, string $name, Carbon $start, Carbon $end, in
array_push($this->data, [
$id,
$name,
+ null,
$start->format('Y-m-d'),
$end->format('Y-m-d'),
$duration * 24 * 60 * 60 * 1000,
From bbc9e12cd85ff5cfd7b6a356b637fde62aab87b1 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 12:21:21 -0300
Subject: [PATCH 10/38] Update GanttChartTable.php
---
src/DataTables/GanttChartTable.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index 9e35abf..d6646fc 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -12,8 +12,8 @@ public function addTask(string $id, string $name, Carbon $start, Carbon $end, in
$id,
$name,
null,
- $start->format('Y-m-d'),
- $end->format('Y-m-d'),
+ "Date(".$start->format('Y,m,d').")",
+ "Date(".$end->format('Y,m,d').")",
$duration * 24 * 60 * 60 * 1000,
$completion,
$dependencies
From 269b71ee987a18673beda890fe859da601df8867 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 12:23:08 -0300
Subject: [PATCH 11/38] Update GanttChartTable.php
---
src/DataTables/GanttChartTable.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index d6646fc..833d62b 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -12,8 +12,8 @@ public function addTask(string $id, string $name, Carbon $start, Carbon $end, in
$id,
$name,
null,
- "Date(".$start->format('Y,m,d').")",
- "Date(".$end->format('Y,m,d').")",
+ "Date(".$start->format('Y,M,D').")",
+ "Date(".$end->format('Y,M,D').")",
$duration * 24 * 60 * 60 * 1000,
$completion,
$dependencies
From 4195dd587250cc06218161b2acd51ecede7f83f2 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 12:26:18 -0300
Subject: [PATCH 12/38] Update GanttChartTable.php
---
src/DataTables/GanttChartTable.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index 833d62b..5f1c2ae 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -12,8 +12,8 @@ public function addTask(string $id, string $name, Carbon $start, Carbon $end, in
$id,
$name,
null,
- "Date(".$start->format('Y,M,D').")",
- "Date(".$end->format('Y,M,D').")",
+ "Date(".$start->year.','.($start->month - 1).','.$start->day.")",
+ "Date(".$end->year.','.($end->month - 1).','.$end->day.")",
$duration * 24 * 60 * 60 * 1000,
$completion,
$dependencies
From 950a971855012417b55119fdf2d1f60cb9f6e2f2 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 12:45:57 -0300
Subject: [PATCH 13/38] Update GanttChartTable.php
---
src/DataTables/GanttChartTable.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index 5f1c2ae..bf96335 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -12,8 +12,8 @@ public function addTask(string $id, string $name, Carbon $start, Carbon $end, in
$id,
$name,
null,
- "Date(".$start->year.','.($start->month - 1).','.$start->day.")",
- "Date(".$end->year.','.($end->month - 1).','.$end->day.")",
+ "Date(".$start->year.','.($start->month - 1).','.$start->day.",0,0,0,0)",
+ "Date(".$end->year.','.($end->month - 1).','.$end->day.",0,0,0,0)",
$duration * 24 * 60 * 60 * 1000,
$completion,
$dependencies
From 8e193305c446e14e88ebed7da36714a34bdd88c5 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 12:50:42 -0300
Subject: [PATCH 14/38] Update GanttChartTable.php
---
src/DataTables/GanttChartTable.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index bf96335..d3e1266 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -12,8 +12,8 @@ public function addTask(string $id, string $name, Carbon $start, Carbon $end, in
$id,
$name,
null,
- "Date(".$start->year.','.($start->month - 1).','.$start->day.",0,0,0,0)",
- "Date(".$end->year.','.($end->month - 1).','.$end->day.",0,0,0,0)",
+ new Date(".$start->year.','.($start->month - 1).','.$start->day.",0,0,0,0),
+ new Date(".$end->year.','.($end->month - 1).','.$end->day.",0,0,0,0),
$duration * 24 * 60 * 60 * 1000,
$completion,
$dependencies
From e422d9f96c8e3cb1625177e03ab5526198e3ea81 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 12:53:59 -0300
Subject: [PATCH 15/38] Test
---
src/DataTables/GanttChartTable.php | 5 +++--
src/Dummies/Date.php | 10 ++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
create mode 100644 src/Dummies/Date.php
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index d3e1266..b11049d 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -3,6 +3,7 @@
namespace Helvetiapps\LagoonCharts\DataTables;
use Carbon\Carbon;
+use Helvetiapps\LagoonCharts\Dummies\Date;
class GanttChartTable{
private $data = [];
@@ -12,8 +13,8 @@ public function addTask(string $id, string $name, Carbon $start, Carbon $end, in
$id,
$name,
null,
- new Date(".$start->year.','.($start->month - 1).','.$start->day.",0,0,0,0),
- new Date(".$end->year.','.($end->month - 1).','.$end->day.",0,0,0,0),
+ new Date($start->year,($start->month - 1),$start->day,0,0,0,0),
+ new Date($end->year,($end->month - 1),$end->day,0,0,0,0),
$duration * 24 * 60 * 60 * 1000,
$completion,
$dependencies
diff --git a/src/Dummies/Date.php b/src/Dummies/Date.php
new file mode 100644
index 0000000..9e1e28c
--- /dev/null
+++ b/src/Dummies/Date.php
@@ -0,0 +1,10 @@
+
Date: Tue, 6 Dec 2022 12:56:17 -0300
Subject: [PATCH 16/38] Test
---
src/DataTables/GanttChartTable.php | 1 +
src/Dummies/Date.php | 10 ----------
2 files changed, 1 insertion(+), 10 deletions(-)
delete mode 100644 src/Dummies/Date.php
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index b11049d..f498a4e 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -4,6 +4,7 @@
use Carbon\Carbon;
use Helvetiapps\LagoonCharts\Dummies\Date;
+use Illuminate\Support\Facades\Date;
class GanttChartTable{
private $data = [];
diff --git a/src/Dummies/Date.php b/src/Dummies/Date.php
deleted file mode 100644
index 9e1e28c..0000000
--- a/src/Dummies/Date.php
+++ /dev/null
@@ -1,10 +0,0 @@
-
Date: Tue, 6 Dec 2022 12:59:56 -0300
Subject: [PATCH 17/38] Update GanttChartTable.php
---
src/DataTables/GanttChartTable.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index f498a4e..253a975 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -3,7 +3,6 @@
namespace Helvetiapps\LagoonCharts\DataTables;
use Carbon\Carbon;
-use Helvetiapps\LagoonCharts\Dummies\Date;
use Illuminate\Support\Facades\Date;
class GanttChartTable{
From 7b0afadf159fabf273019e24f372f8e3ac5602c7 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 13:03:42 -0300
Subject: [PATCH 18/38] Update GanttChartTable.php
---
src/DataTables/GanttChartTable.php | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index 253a975..c34bc5b 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -3,21 +3,22 @@
namespace Helvetiapps\LagoonCharts\DataTables;
use Carbon\Carbon;
-use Illuminate\Support\Facades\Date;
class GanttChartTable{
private $data = [];
public function addTask(string $id, string $name, Carbon $start, Carbon $end, int $duration, int $completion, ?string $dependencies){
- array_push($this->data, [
- $id,
- $name,
- null,
- new Date($start->year,($start->month - 1),$start->day,0,0,0,0),
- new Date($end->year,($end->month - 1),$end->day,0,0,0,0),
- $duration * 24 * 60 * 60 * 1000,
- $completion,
- $dependencies
+ array_push($this->data, [ "c" =>
+ [
+ "v" => $id,
+ "v" => $name,
+ "v" => null,
+ "v" => "Date(".$start->year.','.($start->month - 1).','.$start->day.")",
+ "v" => "Date(".$end->year.','.($end->month - 1).','.$end->day.")",
+ "v" => $duration * 24 * 60 * 60 * 1000,
+ "v" => $completion,
+ "v" => $dependencies
+ ]
]);
}
From f49c3c75a437c697f5a7f30ea0786b7d5575ef08 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 13:10:37 -0300
Subject: [PATCH 19/38] Update GanttChartTable.php
---
src/DataTables/GanttChartTable.php | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index c34bc5b..4d031b2 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -8,23 +8,29 @@ class GanttChartTable{
private $data = [];
public function addTask(string $id, string $name, Carbon $start, Carbon $end, int $duration, int $completion, ?string $dependencies){
- array_push($this->data, [ "c" =>
- [
- "v" => $id,
- "v" => $name,
- "v" => null,
- "v" => "Date(".$start->year.','.($start->month - 1).','.$start->day.")",
- "v" => "Date(".$end->year.','.($end->month - 1).','.$end->day.")",
- "v" => $duration * 24 * 60 * 60 * 1000,
- "v" => $completion,
- "v" => $dependencies
- ]
+ array_push($this->data, [
+ $id,
+ $name,
+ null,
+ "Date(".$start->year.','.($start->month - 1).','.$start->day.")",
+ "Date(".$end->year.','.($end->month - 1).','.$end->day.")",
+ $duration * 24 * 60 * 60 * 1000,
+ $completion,
+ $dependencies
]);
}
public function __toString()
{
- return json_encode($this->data);
+ $str = "[";
+
+ foreach($this->data as $item){
+ $str .= "{c: [{v: '".$item[0]."', {v: '".$item[1]."'}, {v: '".$item[2]."'}, {v: '".$item[3]."'}, {v: '".$item[4]."'}, {v: '".$item[5]."'}, {v: '".$item[6]."'}, {v: '".$item[7]."'}]}\r\n";
+ }
+
+ $str .= "]";
+
+ return $str;
}
public function toArray():array{
From bbaac6b96830a9c6e4ab7f9f075319d8a086c828 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 13:18:58 -0300
Subject: [PATCH 20/38] Update gantt-chart.blade.php
---
resources/views/livewire/gantt-chart.blade.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/resources/views/livewire/gantt-chart.blade.php b/resources/views/livewire/gantt-chart.blade.php
index 8307ce8..07e33be 100644
--- a/resources/views/livewire/gantt-chart.blade.php
+++ b/resources/views/livewire/gantt-chart.blade.php
@@ -17,7 +17,7 @@
google.charts.setOnLoadCallback(drawChart{{ $chartId }});
function drawChart{{ $chartId }}() {
- var data = new google.visualization.DataTable();
+ var data = new google.visualization.DataTable({ rows: @json($chartData)});
data.addColumn('string', 'Task ID');
data.addColumn('string', 'Task Name');
@@ -28,7 +28,7 @@ function drawChart{{ $chartId }}() {
data.addColumn('number', 'Percent Complete');
data.addColumn('string', 'Dependencies');
- data.addRows(@json($chartData));
+ // data.addRows(@json($chartData));
var options = @json($optionsArray);
From 1eea2b4ef5e7b658a27c83ad027e8cf7280f4fa9 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 13:20:32 -0300
Subject: [PATCH 21/38] Update gantt-chart.blade.php
---
resources/views/livewire/gantt-chart.blade.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/views/livewire/gantt-chart.blade.php b/resources/views/livewire/gantt-chart.blade.php
index 07e33be..5e2bad5 100644
--- a/resources/views/livewire/gantt-chart.blade.php
+++ b/resources/views/livewire/gantt-chart.blade.php
@@ -17,7 +17,7 @@
google.charts.setOnLoadCallback(drawChart{{ $chartId }});
function drawChart{{ $chartId }}() {
- var data = new google.visualization.DataTable({ rows: @json($chartData)});
+ var data = new google.visualization.DataTable({ rows: {{ $chartData }} });
data.addColumn('string', 'Task ID');
data.addColumn('string', 'Task Name');
From 5387145a65ff3ca4d0308aaa081f0346b0aecd82 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 13:21:31 -0300
Subject: [PATCH 22/38] Update gantt-chart.blade.php
---
resources/views/livewire/gantt-chart.blade.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/views/livewire/gantt-chart.blade.php b/resources/views/livewire/gantt-chart.blade.php
index 5e2bad5..81432c6 100644
--- a/resources/views/livewire/gantt-chart.blade.php
+++ b/resources/views/livewire/gantt-chart.blade.php
@@ -17,7 +17,7 @@
google.charts.setOnLoadCallback(drawChart{{ $chartId }});
function drawChart{{ $chartId }}() {
- var data = new google.visualization.DataTable({ rows: {{ $chartData }} });
+ var data = new google.visualization.DataTable({ rows: {!! $chartData !!} });
data.addColumn('string', 'Task ID');
data.addColumn('string', 'Task Name');
From cc1d08345fe3013c94a1aa483ec9f1d60c2d36ec Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 13:22:50 -0300
Subject: [PATCH 23/38] Update GanttChartTable.php
---
src/DataTables/GanttChartTable.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index 4d031b2..4ba27fc 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -25,7 +25,7 @@ public function __toString()
$str = "[";
foreach($this->data as $item){
- $str .= "{c: [{v: '".$item[0]."', {v: '".$item[1]."'}, {v: '".$item[2]."'}, {v: '".$item[3]."'}, {v: '".$item[4]."'}, {v: '".$item[5]."'}, {v: '".$item[6]."'}, {v: '".$item[7]."'}]}\r\n";
+ $str .= "{c: [{v: '".$item[0]."'}, {v: '".$item[1]."'}, {v: '".$item[2]."'}, {v: '".$item[3]."'}, {v: '".$item[4]."'}, {v: '".$item[5]."'}, {v: '".$item[6]."'}, {v: '".$item[7]."'}]}\r\n";
}
$str .= "]";
From e46574be1c94b65e9c113c7406a8b4e25fa14947 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 13:26:42 -0300
Subject: [PATCH 24/38] Update GanttChartTable.php
---
src/DataTables/GanttChartTable.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/DataTables/GanttChartTable.php b/src/DataTables/GanttChartTable.php
index 4ba27fc..5a90f5a 100644
--- a/src/DataTables/GanttChartTable.php
+++ b/src/DataTables/GanttChartTable.php
@@ -24,8 +24,13 @@ public function __toString()
{
$str = "[";
+ $count = 0;
foreach($this->data as $item){
- $str .= "{c: [{v: '".$item[0]."'}, {v: '".$item[1]."'}, {v: '".$item[2]."'}, {v: '".$item[3]."'}, {v: '".$item[4]."'}, {v: '".$item[5]."'}, {v: '".$item[6]."'}, {v: '".$item[7]."'}]}\r\n";
+ if($count > 0){
+ $str .= ",";
+ }
+ $count++;
+ $str .= "{c: [{v: '".$item[0]."'}, {v: '".$item[1]."'}, {v: '".$item[2]."'}, {v: '".$item[3]."'}, {v: '".$item[4]."'}, {v: '".$item[5]."'}, {v: '".$item[6]."'}, {v: '".$item[7]."'}]}";
}
$str .= "]";
From a9c6ecc02adbbcb1255eaea3ca631c8dbafe612f Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 13:32:47 -0300
Subject: [PATCH 25/38] Update gantt-chart.blade.php
---
.../views/livewire/gantt-chart.blade.php | 35 +++++++++++++------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/resources/views/livewire/gantt-chart.blade.php b/resources/views/livewire/gantt-chart.blade.php
index 81432c6..9f481b4 100644
--- a/resources/views/livewire/gantt-chart.blade.php
+++ b/resources/views/livewire/gantt-chart.blade.php
@@ -17,16 +17,31 @@
google.charts.setOnLoadCallback(drawChart{{ $chartId }});
function drawChart{{ $chartId }}() {
- var data = new google.visualization.DataTable({ rows: {!! $chartData !!} });
-
- data.addColumn('string', 'Task ID');
- data.addColumn('string', 'Task Name');
- data.addColumn('string', 'Resource');
- data.addColumn('date', 'Start Date');
- data.addColumn('date', 'End Date');
- data.addColumn('number', 'Duration');
- data.addColumn('number', 'Percent Complete');
- data.addColumn('string', 'Dependencies');
+ var data = new google.visualization.DataTable(
+ {
+ cols:
+ [
+ {id: 'id', label: 'Task ID', type: 'string'},
+ {id: 'name', label: 'Task Name', type: 'string'},
+ {id: 'resource', label: 'Resource', type: 'string'},
+ {id: 'start', label: 'Start Date', type: 'date'},
+ {id: 'end', label: 'End Date', type: 'date'},
+ {id: 'duration', label: 'Duration', type: 'number'},
+ {id: 'percent', label: 'Percent Complete', type: 'number'},
+ {id: 'dependencies', label: 'Dependencies', type: 'string'}
+ ],
+ rows: {!! $chartData !!}
+ }
+ );
+
+ // data.addColumn('string', 'Task ID');
+ // data.addColumn('string', 'Task Name');
+ // data.addColumn('string', 'Resource');
+ // data.addColumn('date', 'Start Date');
+ // data.addColumn('date', 'End Date');
+ // data.addColumn('number', 'Duration');
+ // data.addColumn('number', 'Percent Complete');
+ // data.addColumn('string', 'Dependencies');
// data.addRows(@json($chartData));
From b2a75c84afa320d5baf7b0122f88bc63c7c9df3d Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 13:35:24 -0300
Subject: [PATCH 26/38] Removed Title from GanttChart
---
resources/views/livewire/gantt-chart.blade.php | 11 -----------
src/Http/Livewire/GanttChart.php | 5 +----
2 files changed, 1 insertion(+), 15 deletions(-)
diff --git a/resources/views/livewire/gantt-chart.blade.php b/resources/views/livewire/gantt-chart.blade.php
index 9f481b4..9d8f8bc 100644
--- a/resources/views/livewire/gantt-chart.blade.php
+++ b/resources/views/livewire/gantt-chart.blade.php
@@ -34,17 +34,6 @@ function drawChart{{ $chartId }}() {
}
);
- // data.addColumn('string', 'Task ID');
- // data.addColumn('string', 'Task Name');
- // data.addColumn('string', 'Resource');
- // data.addColumn('date', 'Start Date');
- // data.addColumn('date', 'End Date');
- // data.addColumn('number', 'Duration');
- // data.addColumn('number', 'Percent Complete');
- // data.addColumn('string', 'Dependencies');
-
- // data.addRows(@json($chartData));
-
var options = @json($optionsArray);
var chart = new google.visualization.Gantt(document.getElementById('{{ $chartId.$random }}'));
diff --git a/src/Http/Livewire/GanttChart.php b/src/Http/Livewire/GanttChart.php
index 7da3ef7..af4d992 100644
--- a/src/Http/Livewire/GanttChart.php
+++ b/src/Http/Livewire/GanttChart.php
@@ -7,7 +7,6 @@
class GanttChart extends Component
{
- public $title = "NO_TITLE";
public $chartData = [];
public $height;
@@ -24,9 +23,7 @@ class GanttChart extends Component
public $optionsArray;
public function mount(){
- $newOptions = [
- 'title' => $this->title,
- ];
+ $newOptions = [];
if(!is_null($this->height)){
$newOptions["height"] = $this->height;
From aa7136fdbe7c29b5e96574bd2d35e9ca48e5d625 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 13:37:01 -0300
Subject: [PATCH 27/38] Update gantt-chart.blade.php
---
resources/views/livewire/gantt-chart.blade.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/resources/views/livewire/gantt-chart.blade.php b/resources/views/livewire/gantt-chart.blade.php
index 9d8f8bc..95703fc 100644
--- a/resources/views/livewire/gantt-chart.blade.php
+++ b/resources/views/livewire/gantt-chart.blade.php
@@ -34,8 +34,9 @@ function drawChart{{ $chartId }}() {
}
);
- var options = @json($optionsArray);
-
+ @if(count($optionsArray) > 0)
+ var options = @json($optionsArray);
+ @endif
var chart = new google.visualization.Gantt(document.getElementById('{{ $chartId.$random }}'));
chart.draw(data, options);
From ace5181b234d19c32b5d7b68ad76e2eb79de16ca Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 13:38:14 -0300
Subject: [PATCH 28/38] Possible fix for b is null
---
resources/views/livewire/gantt-chart.blade.php | 4 +---
src/Http/Livewire/GanttChart.php | 4 +++-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/resources/views/livewire/gantt-chart.blade.php b/resources/views/livewire/gantt-chart.blade.php
index 95703fc..bb026b2 100644
--- a/resources/views/livewire/gantt-chart.blade.php
+++ b/resources/views/livewire/gantt-chart.blade.php
@@ -34,9 +34,7 @@ function drawChart{{ $chartId }}() {
}
);
- @if(count($optionsArray) > 0)
- var options = @json($optionsArray);
- @endif
+ var options = @json($optionsArray);
var chart = new google.visualization.Gantt(document.getElementById('{{ $chartId.$random }}'));
chart.draw(data, options);
diff --git a/src/Http/Livewire/GanttChart.php b/src/Http/Livewire/GanttChart.php
index af4d992..30a1de7 100644
--- a/src/Http/Livewire/GanttChart.php
+++ b/src/Http/Livewire/GanttChart.php
@@ -23,7 +23,9 @@ class GanttChart extends Component
public $optionsArray;
public function mount(){
- $newOptions = [];
+ $newOptions = [
+ 'title' => 'None'
+ ];
if(!is_null($this->height)){
$newOptions["height"] = $this->height;
From 2ef7dacc8fe7641c3264d90ddb1200df6c858b75 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Tue, 6 Dec 2022 13:43:48 -0300
Subject: [PATCH 29/38] Update README.md
---
README.md | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/README.md b/README.md
index da34628..b2d59ac 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,7 @@ composer require helvetiapps/lagoon-charts
* Pie Charts
* Area Charts
* Bar Charts
+* Gantt Charts (Preview)
## TODO
@@ -95,4 +96,21 @@ $data = $areaChartTable->toArray();
Blade
```
@livewire('lagoon-area-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => [], key('uniquekey'.now()))
+```
+
+### Gantt Chart
+
+Livewire
+```php
+$ganttChartTable = new GanttChartTable();
+
+$ganttChartTable->addTask("test1", "Test1", Carbon::now(), Carbon::now()->copy()->addMonth(), 30, 100, null);
+$ganttChartTable->addTask("test2", "Test2", Carbon::now()->copy()->addMonth(), Carbon::now()->copy()->addMonths(2), 30, 100, "test1");
+
+$data = $ganttChartTable->__toString(); //IMPORTANT USE __toString() here!
+```
+
+Blade
+```
+@livewire('lagoon-gantt-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'options' => [], key('uniquekey'.now()))
```
\ No newline at end of file
From fa0f3718c1a9bc45be816e685986ef7d3e6edc92 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Wed, 7 Dec 2022 08:18:00 -0300
Subject: [PATCH 30/38] Added Column Charts
---
README.md | 17 +++++++
.../views/livewire/column-chart.blade.php | 33 ++++++++++++
src/DataTables/ColumnChartTable.php | 45 ++++++++++++++++
src/Http/Livewire/ColumnChart.php | 51 +++++++++++++++++++
src/LagoonServiceProvider.php | 2 +
5 files changed, 148 insertions(+)
create mode 100644 resources/views/livewire/column-chart.blade.php
create mode 100644 src/DataTables/ColumnChartTable.php
create mode 100644 src/Http/Livewire/ColumnChart.php
diff --git a/README.md b/README.md
index b2d59ac..d113fff 100644
--- a/README.md
+++ b/README.md
@@ -83,6 +83,23 @@ Blade
@livewire('lagoon-bar-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => [], key('uniquekey'.now()))
```
+
+### Bar Chart
+
+Livewire
+```php
+$columnChartTable = new \HelvetiApps\LagoonCharts\DataTables\ColumnChartTable('xAxis', ['yAxis1', 'yAxis2']);
+$columnChartTable->addRow([1, 100, 200]);
+$columnChartTable->addRow([2, 200, 100]);
+$data = $columnChartTable->toArray();
+```
+
+Blade
+```
+@livewire('lagoon-column-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => [], key('uniquekey'.now()))
+```
+
+
### Area Chart
Livewire
diff --git a/resources/views/livewire/column-chart.blade.php b/resources/views/livewire/column-chart.blade.php
new file mode 100644
index 0000000..f12a0cf
--- /dev/null
+++ b/resources/views/livewire/column-chart.blade.php
@@ -0,0 +1,33 @@
+
+ @once
+ @push('styles')
+
+ @endpush
+ @push('headerScripts')
+
+
+ @endpush
+ @endonce
+
+
+
+
+
diff --git a/src/DataTables/ColumnChartTable.php b/src/DataTables/ColumnChartTable.php
new file mode 100644
index 0000000..795f126
--- /dev/null
+++ b/src/DataTables/ColumnChartTable.php
@@ -0,0 +1,45 @@
+colCount = count($yAxisLabels) + 1;
+ $rowCount = 0;
+ $labels = [$xAxisLabel];
+ foreach($yAxisLabels as $label){
+ array_push($labels, $label);
+ }
+ $this->data = [$labels];
+ foreach($rows as $row){
+ $rowCount++;
+ 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);
+ }
+ }
+
+ public function addRow(array $row){
+ if(count($row) != $this->colCount){
+ throw new Exception("Row has ".count($row)." columns but needs to have ".$this->colCount."!");
+ }
+ array_push($this->data, $row);
+ }
+
+ public function __toString()
+ {
+ return json_encode($this->data);
+ }
+
+ public function toArray():array{
+ return $this->data;
+ }
+}
\ No newline at end of file
diff --git a/src/Http/Livewire/ColumnChart.php b/src/Http/Livewire/ColumnChart.php
new file mode 100644
index 0000000..099843e
--- /dev/null
+++ b/src/Http/Livewire/ColumnChart.php
@@ -0,0 +1,51 @@
+ $this->title,
+ ];
+
+ if(!is_null($this->height)){
+ $newOptions["height"] = $this->height;
+ }
+ if(!is_null($this->width)){
+ $newOptions["width"] = $this->width;
+ }
+ if(!is_null($this->options) && is_array($this->options)){
+ foreach($this->options as $key => $value){
+ $newOptions[$key] = $value;
+ }
+ }
+
+ $this->optionsArray = $newOptions;
+ }
+
+ public function render()
+ {
+ $this->random = Carbon::now()->timestamp;
+ return view('lagoon::livewire.column-chart');
+ }
+}
\ No newline at end of file
diff --git a/src/LagoonServiceProvider.php b/src/LagoonServiceProvider.php
index 6811831..27447f0 100644
--- a/src/LagoonServiceProvider.php
+++ b/src/LagoonServiceProvider.php
@@ -6,6 +6,7 @@
use Helvetiapps\LagoonCharts\Http\Livewire\PieChart;
use Helvetiapps\LagoonCharts\Http\Livewire\AreaChart;
use Helvetiapps\LagoonCharts\Http\Livewire\BarChart;
+use Helvetiapps\LagoonCharts\Http\Livewire\ColumnChart;
use Helvetiapps\LagoonCharts\Http\Livewire\GanttChart;
use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;
@@ -25,6 +26,7 @@ public function boot()
Livewire::component('lagoon-area-chart', AreaChart::class);
Livewire::component('lagoon-bar-chart', BarChart::class);
Livewire::component('lagoon-gantt-chart', GanttChart::class);
+ Livewire::component('lagoon-gantt-chart', ColumnChart::class);
if ($this->app->runningInConsole())
{
From b69ad484537737550315477bf55e8711bccc4d08 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Wed, 7 Dec 2022 08:29:15 -0300
Subject: [PATCH 31/38] Added function to add link to png of chart
---
README.md | 20 ++++++++++++++-----
resources/views/livewire/area-chart.blade.php | 7 +++++++
resources/views/livewire/bar-chart.blade.php | 7 +++++++
.../views/livewire/column-chart.blade.php | 7 +++++++
resources/views/livewire/line-chart.blade.php | 7 +++++++
resources/views/livewire/pie-chart.blade.php | 7 +++++++
src/Http/Livewire/AreaChart.php | 2 ++
src/Http/Livewire/BarChart.php | 2 ++
src/Http/Livewire/ColumnChart.php | 2 ++
src/Http/Livewire/LineChart.php | 2 ++
src/Http/Livewire/PieChart.php | 2 ++
11 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index d113fff..da8edc3 100644
--- a/README.md
+++ b/README.md
@@ -64,7 +64,7 @@ $data = $lineChartTable->toArray();
Blade
```
-@livewire('lagoon-line-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => [], key('uniquekey'.now()))
+@livewire('lagoon-line-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => []], key('uniquekey'.now()))
```
@@ -80,7 +80,7 @@ $data = $barChartTable->toArray();
Blade
```
-@livewire('lagoon-bar-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => [], key('uniquekey'.now()))
+@livewire('lagoon-bar-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => []], key('uniquekey'.now()))
```
@@ -96,7 +96,7 @@ $data = $columnChartTable->toArray();
Blade
```
-@livewire('lagoon-column-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => [], key('uniquekey'.now()))
+@livewire('lagoon-column-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => []], key('uniquekey'.now()))
```
@@ -112,7 +112,7 @@ $data = $areaChartTable->toArray();
Blade
```
-@livewire('lagoon-area-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => [], key('uniquekey'.now()))
+@livewire('lagoon-area-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => []], key('uniquekey'.now()))
```
### Gantt Chart
@@ -129,5 +129,15 @@ $data = $ganttChartTable->__toString(); //IMPORTANT USE __toString() here!
Blade
```
-@livewire('lagoon-gantt-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'options' => [], key('uniquekey'.now()))
+@livewire('lagoon-gantt-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'options' => []], key('uniquekey'.now()))
+```
+
+
+### Add link to Chart PNG
+
+You can add a link to a PNG from the chart by adding 'printable' => true, this does only work with corecharts!
+
+Blade
+```
+@livewire('lagoon-area-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => [], 'printable' => true], key('uniquekey'.now()))
```
\ No newline at end of file
diff --git a/resources/views/livewire/area-chart.blade.php b/resources/views/livewire/area-chart.blade.php
index 1d5d38d..edc7af0 100644
--- a/resources/views/livewire/area-chart.blade.php
+++ b/resources/views/livewire/area-chart.blade.php
@@ -26,8 +26,15 @@ function drawChart{{ $chartId }}() {
var chart = new google.visualization.AreaChart(document.getElementById('{{ $chartId.$random }}'));
chart.draw(data, options);
+
+ @if($printable)
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ @endif
}
+ @if($printable)
+
+ @endif
diff --git a/resources/views/livewire/bar-chart.blade.php b/resources/views/livewire/bar-chart.blade.php
index 9931c4b..7843d1e 100644
--- a/resources/views/livewire/bar-chart.blade.php
+++ b/resources/views/livewire/bar-chart.blade.php
@@ -26,8 +26,15 @@ function drawChart{{ $chartId }}() {
var chart = new google.visualization.BarChart(document.getElementById('{{ $chartId.$random }}'));
chart.draw(data, options);
+
+ @if($printable)
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ @endif
}
+ @if($printable)
+
+ @endif
diff --git a/resources/views/livewire/column-chart.blade.php b/resources/views/livewire/column-chart.blade.php
index f12a0cf..df15481 100644
--- a/resources/views/livewire/column-chart.blade.php
+++ b/resources/views/livewire/column-chart.blade.php
@@ -26,8 +26,15 @@ function drawChart{{ $chartId }}() {
var chart = new google.visualization.ColumnChart(document.getElementById('{{ $chartId.$random }}'));
chart.draw(data, options);
+
+ @if($printable)
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ @endif
}
+ @if($printable)
+
+ @endif
diff --git a/resources/views/livewire/line-chart.blade.php b/resources/views/livewire/line-chart.blade.php
index d1c6f6a..8948659 100644
--- a/resources/views/livewire/line-chart.blade.php
+++ b/resources/views/livewire/line-chart.blade.php
@@ -26,8 +26,15 @@ function drawChart{{ $chartId }}() {
var chart = new google.visualization.LineChart(document.getElementById('{{ $chartId.$random }}'));
chart.draw(data, options);
+
+ @if($printable)
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ @endif
}
+ @if($printable)
+
+ @endif
diff --git a/resources/views/livewire/pie-chart.blade.php b/resources/views/livewire/pie-chart.blade.php
index f4de798..d4ad094 100644
--- a/resources/views/livewire/pie-chart.blade.php
+++ b/resources/views/livewire/pie-chart.blade.php
@@ -33,8 +33,15 @@ function drawChart{{ $chartId }}() {
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('{{ $chartId.$random }}'));
chart.draw(data, options);
+
+ @if($printable)
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ @endif
}
+ @if($printable)
+
+ @endif
diff --git a/src/Http/Livewire/AreaChart.php b/src/Http/Livewire/AreaChart.php
index 49798cc..21035ff 100644
--- a/src/Http/Livewire/AreaChart.php
+++ b/src/Http/Livewire/AreaChart.php
@@ -23,6 +23,8 @@ class AreaChart extends Component
public $optionsArray;
+ public $printable = false;
+
public function mount(){
$newOptions = [
'title' => $this->title,
diff --git a/src/Http/Livewire/BarChart.php b/src/Http/Livewire/BarChart.php
index b75ee99..4a21df1 100644
--- a/src/Http/Livewire/BarChart.php
+++ b/src/Http/Livewire/BarChart.php
@@ -22,6 +22,8 @@ class BarChart extends Component
public $random;
public $optionsArray;
+
+ public $printable = false;
public function mount(){
$newOptions = [
diff --git a/src/Http/Livewire/ColumnChart.php b/src/Http/Livewire/ColumnChart.php
index 099843e..c96ecc5 100644
--- a/src/Http/Livewire/ColumnChart.php
+++ b/src/Http/Livewire/ColumnChart.php
@@ -22,6 +22,8 @@ class ColumnChart extends Component
public $random;
public $optionsArray;
+
+ public $printable = false;
public function mount(){
$newOptions = [
diff --git a/src/Http/Livewire/LineChart.php b/src/Http/Livewire/LineChart.php
index b53e49f..24c5c4f 100644
--- a/src/Http/Livewire/LineChart.php
+++ b/src/Http/Livewire/LineChart.php
@@ -19,6 +19,8 @@ class LineChart extends Component
public $random;
public $optionsArray;
+
+ public $printable = false;
public function mount(){
$newOptions = [
diff --git a/src/Http/Livewire/PieChart.php b/src/Http/Livewire/PieChart.php
index 8b5457b..75572f3 100644
--- a/src/Http/Livewire/PieChart.php
+++ b/src/Http/Livewire/PieChart.php
@@ -22,6 +22,8 @@ class PieChart extends Component
public $random;
public $optionsArray;
+
+ public $printable = false;
public function mount(){
$newOptions = [
From 3af9d1a3e96aafa9252808e31fca7cd4483fd669 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Wed, 7 Dec 2022 08:34:01 -0300
Subject: [PATCH 32/38] Centered the "Print" link
---
resources/views/livewire/area-chart.blade.php | 2 +-
resources/views/livewire/bar-chart.blade.php | 2 +-
resources/views/livewire/column-chart.blade.php | 2 +-
resources/views/livewire/line-chart.blade.php | 2 +-
resources/views/livewire/pie-chart.blade.php | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/resources/views/livewire/area-chart.blade.php b/resources/views/livewire/area-chart.blade.php
index edc7af0..6017521 100644
--- a/resources/views/livewire/area-chart.blade.php
+++ b/resources/views/livewire/area-chart.blade.php
@@ -35,6 +35,6 @@ function drawChart{{ $chartId }}() {
@if($printable)
-
+
@endif
diff --git a/resources/views/livewire/bar-chart.blade.php b/resources/views/livewire/bar-chart.blade.php
index 7843d1e..e3bf881 100644
--- a/resources/views/livewire/bar-chart.blade.php
+++ b/resources/views/livewire/bar-chart.blade.php
@@ -35,6 +35,6 @@ function drawChart{{ $chartId }}() {
@if($printable)
-
+
@endif
diff --git a/resources/views/livewire/column-chart.blade.php b/resources/views/livewire/column-chart.blade.php
index df15481..6ae139f 100644
--- a/resources/views/livewire/column-chart.blade.php
+++ b/resources/views/livewire/column-chart.blade.php
@@ -35,6 +35,6 @@ function drawChart{{ $chartId }}() {
@if($printable)
-
+
@endif
diff --git a/resources/views/livewire/line-chart.blade.php b/resources/views/livewire/line-chart.blade.php
index 8948659..576b0bf 100644
--- a/resources/views/livewire/line-chart.blade.php
+++ b/resources/views/livewire/line-chart.blade.php
@@ -35,6 +35,6 @@ function drawChart{{ $chartId }}() {
@if($printable)
-
+
@endif
diff --git a/resources/views/livewire/pie-chart.blade.php b/resources/views/livewire/pie-chart.blade.php
index d4ad094..d2a3a42 100644
--- a/resources/views/livewire/pie-chart.blade.php
+++ b/resources/views/livewire/pie-chart.blade.php
@@ -42,6 +42,6 @@ function drawChart{{ $chartId }}() {
@if($printable)
-
+
@endif
From b8af29458b3c1e1dca913e9599ca17e01642e999 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Wed, 7 Dec 2022 08:35:46 -0300
Subject: [PATCH 33/38] Fixed styling of "Print" link
---
resources/views/livewire/area-chart.blade.php | 4 ++--
resources/views/livewire/bar-chart.blade.php | 4 ++--
resources/views/livewire/column-chart.blade.php | 4 ++--
resources/views/livewire/line-chart.blade.php | 4 ++--
resources/views/livewire/pie-chart.blade.php | 4 ++--
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/resources/views/livewire/area-chart.blade.php b/resources/views/livewire/area-chart.blade.php
index 6017521..b3761ba 100644
--- a/resources/views/livewire/area-chart.blade.php
+++ b/resources/views/livewire/area-chart.blade.php
@@ -28,13 +28,13 @@ function drawChart{{ $chartId }}() {
chart.draw(data, options);
@if($printable)
- document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
@endif
}
@if($printable)
-
+
@endif
diff --git a/resources/views/livewire/bar-chart.blade.php b/resources/views/livewire/bar-chart.blade.php
index e3bf881..ccd301d 100644
--- a/resources/views/livewire/bar-chart.blade.php
+++ b/resources/views/livewire/bar-chart.blade.php
@@ -28,13 +28,13 @@ function drawChart{{ $chartId }}() {
chart.draw(data, options);
@if($printable)
- document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
@endif
}
@if($printable)
-
+
@endif
diff --git a/resources/views/livewire/column-chart.blade.php b/resources/views/livewire/column-chart.blade.php
index 6ae139f..df83654 100644
--- a/resources/views/livewire/column-chart.blade.php
+++ b/resources/views/livewire/column-chart.blade.php
@@ -28,13 +28,13 @@ function drawChart{{ $chartId }}() {
chart.draw(data, options);
@if($printable)
- document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
@endif
}
@if($printable)
-
+
@endif
diff --git a/resources/views/livewire/line-chart.blade.php b/resources/views/livewire/line-chart.blade.php
index 576b0bf..8d94837 100644
--- a/resources/views/livewire/line-chart.blade.php
+++ b/resources/views/livewire/line-chart.blade.php
@@ -28,13 +28,13 @@ function drawChart{{ $chartId }}() {
chart.draw(data, options);
@if($printable)
- document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
@endif
}
@if($printable)
-
+
@endif
diff --git a/resources/views/livewire/pie-chart.blade.php b/resources/views/livewire/pie-chart.blade.php
index d2a3a42..5aefd2f 100644
--- a/resources/views/livewire/pie-chart.blade.php
+++ b/resources/views/livewire/pie-chart.blade.php
@@ -35,13 +35,13 @@ function drawChart{{ $chartId }}() {
chart.draw(data, options);
@if($printable)
- document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
@endif
}
@if($printable)
-
+
@endif
From 1a195bfce1795d0072f598381f2f1ce11979d125 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Wed, 7 Dec 2022 08:55:03 -0300
Subject: [PATCH 34/38] Update line-chart.blade.php
---
resources/views/livewire/line-chart.blade.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/views/livewire/line-chart.blade.php b/resources/views/livewire/line-chart.blade.php
index 8d94837..d29cc7a 100644
--- a/resources/views/livewire/line-chart.blade.php
+++ b/resources/views/livewire/line-chart.blade.php
@@ -28,7 +28,7 @@ function drawChart{{ $chartId }}() {
chart.draw(data, options);
@if($printable)
- document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = '';
@endif
}
From e69129dd90d740e363205d50c4b494019d515c33 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Wed, 7 Dec 2022 09:01:05 -0300
Subject: [PATCH 35/38] Fixed align of "Print" link
---
resources/views/livewire/area-chart.blade.php | 2 +-
resources/views/livewire/bar-chart.blade.php | 2 +-
resources/views/livewire/column-chart.blade.php | 2 +-
resources/views/livewire/pie-chart.blade.php | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/resources/views/livewire/area-chart.blade.php b/resources/views/livewire/area-chart.blade.php
index b3761ba..a9348f0 100644
--- a/resources/views/livewire/area-chart.blade.php
+++ b/resources/views/livewire/area-chart.blade.php
@@ -28,7 +28,7 @@ function drawChart{{ $chartId }}() {
chart.draw(data, options);
@if($printable)
- document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = '';
@endif
}
diff --git a/resources/views/livewire/bar-chart.blade.php b/resources/views/livewire/bar-chart.blade.php
index ccd301d..8b4dff7 100644
--- a/resources/views/livewire/bar-chart.blade.php
+++ b/resources/views/livewire/bar-chart.blade.php
@@ -28,7 +28,7 @@ function drawChart{{ $chartId }}() {
chart.draw(data, options);
@if($printable)
- document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = '';
@endif
}
diff --git a/resources/views/livewire/column-chart.blade.php b/resources/views/livewire/column-chart.blade.php
index df83654..693c97c 100644
--- a/resources/views/livewire/column-chart.blade.php
+++ b/resources/views/livewire/column-chart.blade.php
@@ -28,7 +28,7 @@ function drawChart{{ $chartId }}() {
chart.draw(data, options);
@if($printable)
- document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = '';
@endif
}
diff --git a/resources/views/livewire/pie-chart.blade.php b/resources/views/livewire/pie-chart.blade.php
index 5aefd2f..246b840 100644
--- a/resources/views/livewire/pie-chart.blade.php
+++ b/resources/views/livewire/pie-chart.blade.php
@@ -35,7 +35,7 @@ function drawChart{{ $chartId }}() {
chart.draw(data, options);
@if($printable)
- document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = 'Print';
+ document.getElementById('lagoon-printable-{{ $chartId.$random }}').outerHTML = '';
@endif
}
From c4c83d3458c90db6d7cabc0d19277caf6e7cdcb1 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Wed, 7 Dec 2022 09:18:16 -0300
Subject: [PATCH 36/38] Added Candlestick Charts
---
README.md | 29 ++++++++++-
.../livewire/candlestick-chart.blade.php | 40 +++++++++++++++
src/DataTables/CandlestickChartTable.php | 45 +++++++++++++++++
src/Http/Livewire/CandlestickChart.php | 50 +++++++++++++++++++
src/LagoonServiceProvider.php | 2 +
5 files changed, 165 insertions(+), 1 deletion(-)
create mode 100644 resources/views/livewire/candlestick-chart.blade.php
create mode 100644 src/DataTables/CandlestickChartTable.php
create mode 100644 src/Http/Livewire/CandlestickChart.php
diff --git a/README.md b/README.md
index da8edc3..51c5414 100644
--- a/README.md
+++ b/README.md
@@ -68,6 +68,22 @@ Blade
```
+### Candlestick Chart
+
+Livewire
+```php
+$candlestickChartTable = new \HelvetiApps\LagoonCharts\DataTables\CandlestickChartTable();
+$candlestickChartTable->addRow([1, 100, 200]);
+$candlestickChartTable->addRow([2, 200, 100]);
+$data = $candlestickChartTable->toArray();
+```
+
+Blade
+```
+@livewire('lagoon-candlestick-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => []], key('uniquekey'.now()))
+```
+
+
### Bar Chart
Livewire
@@ -84,7 +100,7 @@ Blade
```
-### Bar Chart
+### Column Chart
Livewire
```php
@@ -133,6 +149,17 @@ Blade
```
+### Add options to the Charts
+
+You can add options with the 'options' => ['option1' => 'something'] variable.
+You can add all options that are inside the respective Google Chart.
+
+Blade
+```
+@livewire('lagoon-area-chart', ['chartId' => 'uniqueID', 'chartData' => $data, 'height' => 300, 'width' => 400, 'title' => 'Title', 'options' => ['backgroundColor' => 'black']], key('uniquekey'.now()))
+```
+
+
### Add link to Chart PNG
You can add a link to a PNG from the chart by adding 'printable' => true, this does only work with corecharts!
diff --git a/resources/views/livewire/candlestick-chart.blade.php b/resources/views/livewire/candlestick-chart.blade.php
new file mode 100644
index 0000000..b1b5615
--- /dev/null
+++ b/resources/views/livewire/candlestick-chart.blade.php
@@ -0,0 +1,40 @@
+
+ @once
+ @push('styles')
+
+ @endpush
+ @push('headerScripts')
+
+
+ @endpush
+ @endonce
+
+
+
+
+ @if($printable)
+
+ @endif
+
diff --git a/src/DataTables/CandlestickChartTable.php b/src/DataTables/CandlestickChartTable.php
new file mode 100644
index 0000000..ca7f88c
--- /dev/null
+++ b/src/DataTables/CandlestickChartTable.php
@@ -0,0 +1,45 @@
+colCount = count($rows) < 1 ? 0 : count($rows[0]);
+ $rowCount = 0;
+
+ $this->data = [];
+ foreach($rows as $row){
+ $rowCount++;
+ 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);
+ }
+ }
+
+ public function addRow(array $row){
+ if($this->colCount == 0){
+ $this->colCount = count($row);
+ }
+ if(count($row) != $this->colCount){
+ throw new Exception("Row has ".count($row)." columns but needs to have ".$this->colCount."!");
+ }
+ array_push($this->data, $row);
+ }
+
+ public function __toString()
+ {
+ return json_encode($this->data);
+ }
+
+ public function toArray():array{
+ return $this->data;
+ }
+}
\ No newline at end of file
diff --git a/src/Http/Livewire/CandlestickChart.php b/src/Http/Livewire/CandlestickChart.php
new file mode 100644
index 0000000..330b949
--- /dev/null
+++ b/src/Http/Livewire/CandlestickChart.php
@@ -0,0 +1,50 @@
+ $this->title,
+ ];
+
+ if(!is_null($this->height)){
+ $newOptions["height"] = $this->height;
+ }
+ if(!is_null($this->width)){
+ $newOptions["width"] = $this->width;
+ }
+ if(!is_null($this->options) && is_array($this->options)){
+ foreach($this->options as $key => $value){
+ $newOptions[$key] = $value;
+ }
+ }
+
+ $this->optionsArray = $newOptions;
+ }
+
+ public function render()
+ {
+ $this->random = Carbon::now()->timestamp;
+ return view('lagoon::livewire.line-chart');
+ }
+}
diff --git a/src/LagoonServiceProvider.php b/src/LagoonServiceProvider.php
index 27447f0..ac3eded 100644
--- a/src/LagoonServiceProvider.php
+++ b/src/LagoonServiceProvider.php
@@ -6,6 +6,7 @@
use Helvetiapps\LagoonCharts\Http\Livewire\PieChart;
use Helvetiapps\LagoonCharts\Http\Livewire\AreaChart;
use Helvetiapps\LagoonCharts\Http\Livewire\BarChart;
+use Helvetiapps\LagoonCharts\Http\Livewire\CandlestickChart;
use Helvetiapps\LagoonCharts\Http\Livewire\ColumnChart;
use Helvetiapps\LagoonCharts\Http\Livewire\GanttChart;
use Illuminate\Support\ServiceProvider;
@@ -27,6 +28,7 @@ public function boot()
Livewire::component('lagoon-bar-chart', BarChart::class);
Livewire::component('lagoon-gantt-chart', GanttChart::class);
Livewire::component('lagoon-gantt-chart', ColumnChart::class);
+ Livewire::component('lagoon-candlestick-chart', CandlestickChart::class);
if ($this->app->runningInConsole())
{
From eb24965478f262f20ff468bf00a5a4bc52ba934e Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Wed, 7 Dec 2022 09:18:59 -0300
Subject: [PATCH 37/38] Update README.md
---
README.md | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 51c5414..c92057b 100644
--- a/README.md
+++ b/README.md
@@ -20,10 +20,13 @@ composer require helvetiapps/lagoon-charts
## Included Charts
-* Line Charts
-* Pie Charts
+
* Area Charts
* Bar Charts
+* Canldestick Charts
+* Column Charts
+* Line Charts
+* Pie Charts
* Gantt Charts (Preview)
From 894a350be51d5724ce4b5a12f01bd6502ef213a0 Mon Sep 17 00:00:00 2001
From: Roman Wanner <60240491+daredloco@users.noreply.github.com>
Date: Wed, 7 Dec 2022 09:20:39 -0300
Subject: [PATCH 38/38] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index c92057b..73c05c4 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ composer require helvetiapps/lagoon-charts
* Area Charts
* Bar Charts
-* Canldestick Charts
+* Candlestick Charts
* Column Charts
* Line Charts
* Pie Charts