Merge pull request #53 from nicko170/master

Allow setting type on Pie Chart Model
This commit is contained in:
Andrés Santibáñez
2022-02-14 12:22:16 -05:00
committed by GitHub
4 changed files with 29 additions and 12126 deletions

12136
package-lock.json generated

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -20,13 +20,14 @@ const pieChart = () => {
const onSliceClickEventName = component.get('pieChartModel.onSliceClickEventName')
const data = component.get('pieChartModel.data')
const sparkline = component.get('pieChartModel.sparkline')
const type = component.get('pieChartModel.type')
const options = {
series: data.map(item => item.value),
chart: {
height: '100%',
type: 'pie',
type: type,
...sparkline,

View File

@@ -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', []));
}
}