Skip to content

Commit

Permalink
Merge pull request #59 from jamesmills/sparklines
Browse files Browse the repository at this point in the history
Add Sparklines option
  • Loading branch information
ArielMejiaDev authored Jul 12, 2022
2 parents 39a418a + 7583c0a commit 9e1f7e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/LarapexChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class LarapexChart
protected $toolbar;
protected $zoom;
protected $dataLabels;
protected $sparklines;
private $chartLetters = 'abcdefghijklmnopqrstuvwxyz';

/*
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -453,6 +461,14 @@ public function dataLabels()
return $this->dataLabels;
}

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

/*
|--------------------------------------------------------------------------
| JSON Helper
Expand All @@ -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()),
Expand Down Expand Up @@ -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()),
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 9e1f7e0

Please sign in to comment.