Added HasLegend trait

- Refactored component to use BaseChartModel and traits
This commit is contained in:
Andrés Santibáñez
2020-10-25 00:40:06 -05:00
parent 8126b95593
commit 9df03c36a8
9 changed files with 123 additions and 72 deletions

48
src/Models/HasStroke.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
namespace Asantibanez\LivewireCharts\Models;
trait HasStroke
{
private $stroke;
public function initStroke()
{
$this->stroke = $this->defaultStroke();
}
private function defaultStroke()
{
return [
'curve' => 'straight',
];
}
public function setSmoothCurve()
{
data_set($this->stroke, 'curve', 'smooth');
return $this;
}
public function setStraightCurve()
{
data_set($this->stroke, 'curve', 'straight');
return $this;
}
protected function strokeToArray()
{
return [
'stroke' => $this->stroke,
];
}
protected function strokeFromArray($array)
{
$this->stroke = data_get($array, 'stroke', $this->defaultStroke());
}
}