forked from onmotion/yii2-widget-apexcharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApexchartsWidget.php
55 lines (42 loc) · 995 Bytes
/
ApexchartsWidget.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* @copyright Copyright (c) 2018
* @author Alexandr Kozhevnikov <[email protected]>
* @package yii2-widget-apexcharts
*/
namespace onmotion\apexcharts;
use Yii;
use yii\base\Widget;
use yii\db\ActiveRecord;
use yii\helpers\Json;
/**
*
* @property ActiveRecord|null $model
*/
class ApexchartsWidget extends Widget
{
public $id = 'apexcharts-widget';
public $chartOptions = [];
public function init()
{
Yii::setAlias('@apexchartsWidgetRoot', __DIR__);
parent::init();
}
public function getViewPath()
{
return Yii::getAlias('@apexchartsWidgetRoot/views');
}
public function beforeRun()
{
return parent::beforeRun();
}
public function run()
{
parent::run();
ApexchartsWidgetAsset::register($this->getView());
echo $this->render('index', [
'id' => $this->getId(),
'chartOptions' => Json::encode($this->chartOptions),
]);
}
}