feat: merged with master
This commit is contained in:
@@ -8,6 +8,8 @@ trait HasColors
|
||||
{
|
||||
private $colors;
|
||||
|
||||
private $enableShades;
|
||||
|
||||
public function setColors($colors)
|
||||
{
|
||||
$this->colors = $colors;
|
||||
@@ -22,9 +24,25 @@ trait HasColors
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function enableShades()
|
||||
{
|
||||
$this->enableShades = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function disableShades()
|
||||
{
|
||||
$this->enableShades = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function initColors()
|
||||
{
|
||||
$this->colors = $this->defaultColors();
|
||||
|
||||
$this->enableShades = true;
|
||||
}
|
||||
|
||||
private function defaultColors()
|
||||
@@ -35,12 +53,15 @@ trait HasColors
|
||||
protected function colorsFromArray($array)
|
||||
{
|
||||
$this->colors = data_get($array, 'colors', $this->defaultColors());
|
||||
|
||||
$this->enableShades = data_get($array, 'enableShades', true);
|
||||
}
|
||||
|
||||
protected function colorsToArray()
|
||||
{
|
||||
return [
|
||||
'colors' => $this->colors,
|
||||
'enableShades' => $this->enableShades,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ class PieChartModel extends BaseChartModel
|
||||
|
||||
public $opacity;
|
||||
|
||||
public $type;
|
||||
|
||||
public $data;
|
||||
|
||||
public function __construct()
|
||||
@@ -23,6 +25,8 @@ class PieChartModel extends BaseChartModel
|
||||
|
||||
$this->opacity = 0.75;
|
||||
|
||||
$this->type = 'pie';
|
||||
|
||||
$this->data = collect();
|
||||
}
|
||||
|
||||
@@ -33,6 +37,13 @@ class PieChartModel extends BaseChartModel
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withOnSliceClickEvent($onSliceClickEventName)
|
||||
{
|
||||
$this->onSliceClickEventName = $onSliceClickEventName;
|
||||
@@ -57,6 +68,7 @@ class PieChartModel extends BaseChartModel
|
||||
return array_merge(parent::toArray(), [
|
||||
'onSliceClickEventName' => $this->onSliceClickEventName,
|
||||
'opacity' => $this->opacity,
|
||||
'type' => $this->type,
|
||||
'data' => $this->data->toArray(),
|
||||
]);
|
||||
}
|
||||
@@ -69,6 +81,8 @@ class PieChartModel extends BaseChartModel
|
||||
|
||||
$this->opacity = data_get($array, 'opacity', 0.75);
|
||||
|
||||
$this->type = data_get($array, 'type', 'pie');
|
||||
|
||||
$this->data = collect(data_get($array, 'data', []));
|
||||
}
|
||||
}
|
||||
|
||||
95
src/Models/RadarChartModel.php
Normal file
95
src/Models/RadarChartModel.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Asantibanez\LivewireCharts\Models;
|
||||
|
||||
/**
|
||||
* Class ColumnChartModel
|
||||
* @package Asantibanez\LivewireCharts\Models
|
||||
* @property boolean $isMultiColumn
|
||||
* @property boolean $isStacked
|
||||
*/
|
||||
class RadarChartModel extends BaseChartModel
|
||||
{
|
||||
public $opacity;
|
||||
|
||||
public $colors;
|
||||
|
||||
public $onPointClickEventName;
|
||||
|
||||
public $data;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->onPointClickEventName = null;
|
||||
|
||||
$this->opacity = 0.5;
|
||||
|
||||
$this->colors = ['#2E93fA', '#66DA26', '#546E7A', '#E91E63', '#FF9800'];
|
||||
|
||||
$this->data = collect();
|
||||
}
|
||||
|
||||
public function setColors($colors)
|
||||
{
|
||||
$this->colors = $colors;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setOpacity($opacity)
|
||||
{
|
||||
$this->opacity = $opacity;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withOnPointClickEvent($onPointClickEventName)
|
||||
{
|
||||
$this->onPointClickEventName = $onPointClickEventName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function addSeries($seriesName, $title, $value, $extras = [])
|
||||
{
|
||||
$series = $this->data->get($seriesName, collect());
|
||||
|
||||
$series->push([
|
||||
'seriesName' => $seriesName,
|
||||
'title' => $title,
|
||||
'value' => $value,
|
||||
'extras' => $extras,
|
||||
]);
|
||||
|
||||
$this->data->put($seriesName, $series);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return array_merge(parent::toArray(), [
|
||||
'onPointClickEventName' => $this->onPointClickEventName,
|
||||
'opacity' => $this->opacity,
|
||||
'colors' => $this->colors,
|
||||
'data' => $this->data->toArray(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function fromArray($array)
|
||||
{
|
||||
parent::fromArray($array);
|
||||
|
||||
$this->onPointClickEventName = data_get($array, 'onPointClickEventName', null);
|
||||
|
||||
$this->opacity = data_get($array, 'opacity', 0.5);
|
||||
|
||||
$this->colors = data_get($array, 'color', '#90cdf4');
|
||||
|
||||
$this->data = collect(data_get($array, 'data', []));
|
||||
}
|
||||
}
|
||||
84
src/Models/TreeMapChartModel.php
Normal file
84
src/Models/TreeMapChartModel.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Asantibanez\LivewireCharts\Models;
|
||||
|
||||
/**
|
||||
* Class TreeMapChartModel
|
||||
* @package Asantibanez\LivewireCharts\Models
|
||||
*/
|
||||
class TreeMapChartModel extends BaseChartModel
|
||||
{
|
||||
use HasTitle;
|
||||
use HasColors;
|
||||
|
||||
public $data;
|
||||
public $distributed;
|
||||
public $onBlockClickEventName;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->data = collect();
|
||||
|
||||
$this->distributed = false;
|
||||
|
||||
$this->setColors(['#2E93fA']);
|
||||
}
|
||||
|
||||
public function setDistributed($distributed)
|
||||
{
|
||||
$this->distributed = $distributed;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addBlock($title, $value, $extras = [])
|
||||
{
|
||||
return $this->addSeriesBlock($this->title, $title, $value, $extras);
|
||||
}
|
||||
|
||||
public function addSeriesBlock($seriesName, $title, $value, $extras = [])
|
||||
{
|
||||
$series = $this->data->get($seriesName, collect());
|
||||
|
||||
$series->push([
|
||||
'seriesName' => $seriesName,
|
||||
'title' => $title,
|
||||
'value' => $value,
|
||||
'extras' => $extras,
|
||||
]);
|
||||
|
||||
$this->data->put($seriesName, $series);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withOnBlockClickEvent($onBlockClickEventName)
|
||||
{
|
||||
$this->onBlockClickEventName = $onBlockClickEventName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return array_merge(parent::toArray(), [
|
||||
'data' => $this->data->toArray(),
|
||||
'distributed' => $this->distributed,
|
||||
'onBlockClickEventName' => $this->onBlockClickEventName,
|
||||
]);
|
||||
}
|
||||
|
||||
public function fromArray($array)
|
||||
{
|
||||
parent::fromArray($array);
|
||||
|
||||
$this->data = collect(data_get($array, 'data', []));
|
||||
|
||||
$this->distributed = data_get($array, 'distributed', false);
|
||||
|
||||
$this->onBlockClickEventName = data_get($array, 'onBlockClickEventName', null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user