Added ability to specify custom json config to charts
This commit is contained in:
39
src/Models/HasJsonConfig.php
Normal file
39
src/Models/HasJsonConfig.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Asantibanez\LivewireCharts\Models;
|
||||
|
||||
|
||||
trait HasJsonConfig
|
||||
{
|
||||
private $jsonConfig;
|
||||
|
||||
public function setJsonConfig($jsonConfig)
|
||||
{
|
||||
$this->jsonConfig = $jsonConfig;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function initJsonConfig()
|
||||
{
|
||||
$this->jsonConfig = [];
|
||||
}
|
||||
|
||||
private function defaultJsonConfig()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function jsonConfigFromArray($array)
|
||||
{
|
||||
$this->jsonConfig = data_get($array, 'jsonConfig', $this->defaultJsonConfig());
|
||||
}
|
||||
|
||||
protected function jsonConfigToArray()
|
||||
{
|
||||
return [
|
||||
'jsonConfig' => $this->jsonConfig,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user