Skip to content

Commit

Permalink
Merge pull request #95 from zwhhz/configuration-for-visibility-of-the…
Browse files Browse the repository at this point in the history
…-legend

Configuration for the visibility of the legend
  • Loading branch information
ArielMejiaDev authored Feb 8, 2024
2 parents 585e17b + 3d6f210 commit a0ec6ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/LarapexChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class LarapexChart
protected string $grid;
protected string $markers;
protected bool $stacked = false;
protected bool $showLegend = true;
protected string $stroke = '';
protected string $toolbar;
protected string $zoom;
Expand Down Expand Up @@ -278,6 +279,12 @@ public function setStacked(bool $stacked = true): LarapexChart
return $this;
}

public function setShowLegend(bool $showLegend = true): self
{
$this->showLegend = $showLegend;
return $this;
}

/*
|--------------------------------------------------------------------------
| Getters
Expand Down Expand Up @@ -417,6 +424,11 @@ public function stacked(): bool
return $this->stacked;
}

public function showLegend(): string
{
return $this->showLegend ? 'true' : 'false';
}

/*
|--------------------------------------------------------------------------
| JSON Options Builder
Expand Down Expand Up @@ -458,6 +470,9 @@ public function toJson(): \Illuminate\Http\JsonResponse
],
'grid' => json_decode($this->grid()),
'markers' => json_decode($this->markers()),
'legend' => [
'show' => $this->showLegend()
],
];

if($this->labels()) {
Expand Down Expand Up @@ -512,6 +527,9 @@ public function toVue() :array
],
'grid' => json_decode($this->grid()),
'markers' => json_decode($this->markers()),
'legend' => [
'show' => $this->showLegend()
]
];

if($this->labels()) {
Expand Down
3 changes: 3 additions & 0 deletions stubs/resources/views/chart/script.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
@if($chart->stroke())
stroke: {!! $chart->stroke() !!},
@endif
legend: {
show: {!! $chart->showLegend() !!}
}
}
var chart = new ApexCharts(document.querySelector("#{!! $chart->id() !!}"), options);
Expand Down

0 comments on commit a0ec6ef

Please sign in to comment.