Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pandigresik committed Aug 18, 2022
2 parents 480d8f7 + 9e1f7e0 commit 52809a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^7.4|^8.0",
"illuminate/support": "^8.0",
"illuminate/support": "^8.0|^9.0",
"ext-json": "*"
},
"require-dev": {
Expand Down
18 changes: 18 additions & 0 deletions src/LarapexChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class LarapexChart
protected $toolbar;
protected $zoom;
protected $dataLabels;
protected $sparklines;
private $chartLetters = 'abcdefghijklmnopqrstuvwxyz';

/*
Expand All @@ -56,6 +57,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;
Expand Down Expand Up @@ -259,6 +261,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
Expand Down Expand Up @@ -455,6 +463,14 @@ public function dataLabels()
return $this->dataLabels;
}

/**
* @return true|boolean
*/
public function sparklines()
{
return $this->sparklines;
}

/*
|--------------------------------------------------------------------------
| JSON Helper
Expand All @@ -472,6 +488,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()),
Expand Down Expand Up @@ -516,6 +533,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()),
Expand Down
3 changes: 2 additions & 1 deletion stubs/resources/views/chart/script.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() !!}
Expand Down

0 comments on commit 52809a2

Please sign in to comment.