Extracted title property to trait

This commit is contained in:
Andrés Santibáñez
2020-11-03 07:20:46 -05:00
parent 22b72c1980
commit 63fe7a1533
6 changed files with 43 additions and 57 deletions

View File

@@ -8,13 +8,10 @@ use Illuminate\Support\Collection;
/**
* Class LineChartModel
* @package Asantibanez\LivewireCharts\Models
* @property string $title
* @property boolean $isMultiLine
*/
class LineChartModel extends BaseChartModel
{
public $title;
public $isMultiLine;
public $data;
@@ -27,8 +24,6 @@ class LineChartModel extends BaseChartModel
{
parent::__construct();
$this->title = '';
$this->isMultiLine = false;
$this->onPointClickEventName = null;
@@ -56,13 +51,6 @@ class LineChartModel extends BaseChartModel
return $this;
}
public function setTitle($title)
{
$this->title = $title;
return $this;
}
public function addPoint($title, $value, $extras = [])
{
$this->data->push([
@@ -119,7 +107,6 @@ class LineChartModel extends BaseChartModel
public function toArray()
{
return array_merge(parent::toArray(), [
'title' => $this->title,
'isMultiLine' => $this->isMultiLine,
'onPointClickEventName' => $this->onPointClickEventName,
'data' => $this->data->toArray(),
@@ -131,8 +118,6 @@ class LineChartModel extends BaseChartModel
{
parent::fromArray($array);
$this->title = data_get($array, 'title', '');
$this->isMultiLine = data_get($array, 'isMultiLine', false);
$this->onPointClickEventName = data_get($array, 'onPointClickEventName', null);