diff --git a/src/LarapexChart.php b/src/LarapexChart.php index 283d50d..fb7fe33 100644 --- a/src/LarapexChart.php +++ b/src/LarapexChart.php @@ -35,6 +35,7 @@ class LarapexChart protected $toolbar; protected $zoom; protected $dataLabels; + protected $sparklines; private $chartLetters = 'abcdefghijklmnopqrstuvwxyz'; /* @@ -54,6 +55,7 @@ public function __construct() $this->toolbar = json_encode(['show' => false]); $this->zoom = json_encode(['enabled' => true]); $this->dataLabels = json_encode(['enabled' => false]); + $this->sparklines = json_encode(['enabled' => false]); $this->fontFamily = json_encode(config('larapex-charts.font_family')); $this->foreColor = config('larapex-charts.font_color'); return $this; @@ -257,6 +259,12 @@ public function setDataLabels(bool $enabled = true) :LarapexChart return $this; } + public function setSparklines(bool $enabled = true): LarapexChart + { + $this->sparklines = json_encode(['enabled' => $enabled]); + return $this; + } + /* |-------------------------------------------------------------------------- | Getters @@ -453,6 +461,14 @@ public function dataLabels() return $this->dataLabels; } + /** + * @return true|boolean + */ + public function sparklines() + { + return $this->sparklines; + } + /* |-------------------------------------------------------------------------- | JSON Helper @@ -470,6 +486,7 @@ public function toJson() 'zoom' => json_decode($this->zoom()), 'fontFamily' => json_decode($this->fontFamily()), 'foreColor' => $this->foreColor(), + 'sparklines' => $this->sparklines(), ], 'plotOptions' => [ 'bar' => json_decode($this->horizontal()), @@ -514,6 +531,7 @@ public function toVue() :array 'zoom' => json_decode($this->zoom()), 'fontFamily' => json_decode($this->fontFamily()), 'foreColor' => $this->foreColor(), + 'sparkline' => json_decode($this->sparklines()), ], 'plotOptions' => [ 'bar' => json_decode($this->horizontal()), diff --git a/stubs/resources/views/chart/script.blade.php b/stubs/resources/views/chart/script.blade.php index d3fd028..51b9884 100644 --- a/stubs/resources/views/chart/script.blade.php +++ b/stubs/resources/views/chart/script.blade.php @@ -8,7 +8,8 @@ toolbar: {!! $chart->toolbar() !!}, zoom: {!! $chart->zoom() !!}, fontFamily: '{!! $chart->fontFamily() !!}', - foreColor: '{!! $chart->foreColor() !!}' + foreColor: '{!! $chart->foreColor() !!}', + sparkline: {!! $chart->sparklines() !!} }, plotOptions: { bar: {!! $chart->horizontal() !!}