Skip to content

Commit a0ec6ef

Browse files
Merge pull request #95 from zwhhz/configuration-for-visibility-of-the-legend
Configuration for the visibility of the legend
2 parents 585e17b + 3d6f210 commit a0ec6ef

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/LarapexChart.php

+18
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class LarapexChart
3434
protected string $grid;
3535
protected string $markers;
3636
protected bool $stacked = false;
37+
protected bool $showLegend = true;
3738
protected string $stroke = '';
3839
protected string $toolbar;
3940
protected string $zoom;
@@ -278,6 +279,12 @@ public function setStacked(bool $stacked = true): LarapexChart
278279
return $this;
279280
}
280281

282+
public function setShowLegend(bool $showLegend = true): self
283+
{
284+
$this->showLegend = $showLegend;
285+
return $this;
286+
}
287+
281288
/*
282289
|--------------------------------------------------------------------------
283290
| Getters
@@ -417,6 +424,11 @@ public function stacked(): bool
417424
return $this->stacked;
418425
}
419426

427+
public function showLegend(): string
428+
{
429+
return $this->showLegend ? 'true' : 'false';
430+
}
431+
420432
/*
421433
|--------------------------------------------------------------------------
422434
| JSON Options Builder
@@ -458,6 +470,9 @@ public function toJson(): \Illuminate\Http\JsonResponse
458470
],
459471
'grid' => json_decode($this->grid()),
460472
'markers' => json_decode($this->markers()),
473+
'legend' => [
474+
'show' => $this->showLegend()
475+
],
461476
];
462477

463478
if($this->labels()) {
@@ -512,6 +527,9 @@ public function toVue() :array
512527
],
513528
'grid' => json_decode($this->grid()),
514529
'markers' => json_decode($this->markers()),
530+
'legend' => [
531+
'show' => $this->showLegend()
532+
]
515533
];
516534

517535
if($this->labels()) {

stubs/resources/views/chart/script.blade.php

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
@if($chart->stroke())
3939
stroke: {!! $chart->stroke() !!},
4040
@endif
41+
legend: {
42+
show: {!! $chart->showLegend() !!}
43+
}
4144
}
4245
4346
var chart = new ApexCharts(document.querySelector("#{!! $chart->id() !!}"), options);

0 commit comments

Comments
 (0)