From 75d31076e483dbfb5885d68fc3da0b8f8f404118 Mon Sep 17 00:00:00 2001 From: Ralph Morris Date: Fri, 23 Feb 2024 15:52:02 +0000 Subject: [PATCH] add ability to not show labels on xaxis --- src/LarapexChart.php | 18 ++++++++++++++++++ stubs/resources/views/chart/script.blade.php | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/LarapexChart.php b/src/LarapexChart.php index fa6dc36..c6d720f 100644 --- a/src/LarapexChart.php +++ b/src/LarapexChart.php @@ -35,6 +35,7 @@ class LarapexChart protected string $markers; protected bool $stacked = false; protected bool $showLegend = true; + protected bool $showXAxisLabels = true; protected string $stroke = ''; protected string $toolbar; protected string $zoom; @@ -285,6 +286,12 @@ public function setShowLegend(bool $showLegend = true): self return $this; } + public function setShowXAxisLabels(bool $showXAxisLabels = true): self + { + $this->showXAxisLabels = $showXAxisLabels; + return $this; + } + /* |-------------------------------------------------------------------------- | Getters @@ -429,6 +436,11 @@ public function showLegend(): string return $this->showLegend ? 'true' : 'false'; } + public function showXAxisLabels(): bool + { + return $this->showXAxisLabels; + } + /* |-------------------------------------------------------------------------- | JSON Options Builder @@ -467,6 +479,9 @@ public function toJson(): \Illuminate\Http\JsonResponse ], 'xaxis' => [ 'categories' => json_decode($this->xAxis()), + 'labels' => [ + 'show' => $this->showXAxisLabels(), + ] ], 'grid' => json_decode($this->grid()), 'markers' => json_decode($this->markers()), @@ -524,6 +539,9 @@ public function toVue() :array ], 'xaxis' => [ 'categories' => json_decode($this->xAxis()), + 'labels' => [ + 'show' => $this->showXAxisLabels(), + ] ], 'grid' => json_decode($this->grid()), 'markers' => json_decode($this->markers()), diff --git a/stubs/resources/views/chart/script.blade.php b/stubs/resources/views/chart/script.blade.php index 3e101ac..f0bf56b 100644 --- a/stubs/resources/views/chart/script.blade.php +++ b/stubs/resources/views/chart/script.blade.php @@ -31,7 +31,10 @@ align: '{!! $chart->subtitlePosition() !!}' }, xaxis: { - categories: {!! $chart->xAxis() !!} + categories: {!! $chart->xAxis() !!}, + labels : { + show: {!! $chart->showXAxisLabels() !!} + } }, grid: {!! $chart->grid() !!}, markers: {!! $chart->markers() !!},