Added HasLegend trait
- Refactored component to use BaseChartModel and traits
This commit is contained in:
48
src/Models/HasStroke.php
Normal file
48
src/Models/HasStroke.php
Normal 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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user