Initial commit
This commit is contained in:
36
src/Charts/LivewirePieChart.php
Normal file
36
src/Charts/LivewirePieChart.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Asantibanez\LivewireCharts\Charts;
|
||||
|
||||
use Asantibanez\LivewireCharts\Models\PieChartModel;
|
||||
use Livewire\Component;
|
||||
|
||||
/**
|
||||
* Class PieChart
|
||||
* @package Asantibanez\LivewireCharts\Charts
|
||||
*/
|
||||
class LivewirePieChart extends Component
|
||||
{
|
||||
public $pieChartModel;
|
||||
|
||||
public function mount(PieChartModel $pieChartModel)
|
||||
{
|
||||
$this->pieChartModel = $pieChartModel->toArray();
|
||||
}
|
||||
|
||||
public function onSliceClick($slice)
|
||||
{
|
||||
$onSliceClickEventName = data_get($this->pieChartModel, 'onSliceClickEventName', null);
|
||||
|
||||
if ($onSliceClickEventName === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->emit($onSliceClickEventName, $slice);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire-charts::livewire-pie-chart');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user