Added Area Chart component and model
This commit is contained in:
36
src/Charts/LivewireAreaChart.php
Executable file
36
src/Charts/LivewireAreaChart.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Asantibanez\LivewireCharts\Charts;
|
||||
|
||||
use Asantibanez\LivewireCharts\Models\AreaChartModel;
|
||||
use Livewire\Component;
|
||||
|
||||
/**
|
||||
* Class LivewireAreaChart
|
||||
* @package Asantibanez\LivewireCharts\Charts
|
||||
*/
|
||||
class LivewireAreaChart extends Component
|
||||
{
|
||||
public $areaChartModel;
|
||||
|
||||
public function mount(AreaChartModel $areaChartModel)
|
||||
{
|
||||
$this->areaChartModel = $areaChartModel->toArray();
|
||||
}
|
||||
|
||||
public function onPointClick($point)
|
||||
{
|
||||
$onPointClickEventName = data_get($this->areaChartModel, 'onPointClickEventName', null);
|
||||
|
||||
if ($onPointClickEventName === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->emit($onPointClickEventName, $point);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire-charts::livewire-area-chart');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user