Added new traits for colors and grid handling
This commit is contained in:
66
src/Models/HasGrid.php
Normal file
66
src/Models/HasGrid.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Asantibanez\LivewireCharts\Models;
|
||||
|
||||
|
||||
trait HasGrid
|
||||
{
|
||||
private $grid;
|
||||
|
||||
public function setGridVisible($visible)
|
||||
{
|
||||
data_set($this->grid, 'show', $visible);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withGrid()
|
||||
{
|
||||
data_set($this->grid, 'show', true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withoutGrid()
|
||||
{
|
||||
data_set($this->grid, 'show', false);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function initGrid()
|
||||
{
|
||||
$this->grid = $this->defaultGrid();
|
||||
}
|
||||
|
||||
private function defaultGrid()
|
||||
{
|
||||
return [
|
||||
'show' => false,
|
||||
'position' => 'back',
|
||||
'xaxis' => [
|
||||
'lines' => [
|
||||
'show' => true,
|
||||
],
|
||||
],
|
||||
'yaxis' => [
|
||||
'lines' => [
|
||||
'show' => true,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
protected function gridFromArray($array)
|
||||
{
|
||||
$this->grid = data_get($array, 'grid', $this->defaultGrid());
|
||||
}
|
||||
|
||||
protected function gridToArray()
|
||||
{
|
||||
return [
|
||||
'grid' => $this->grid,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user