From f0fb3f66d095b3fb47f1392318f1879c1e805f63 Mon Sep 17 00:00:00 2001 From: Cosmo Date: Sat, 4 Nov 2017 13:10:11 +0800 Subject: [PATCH] Supports register extensions --- src/ECharts.php | 5 +++++ src/EChartsAsset.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/ECharts.php b/src/ECharts.php index e083433..2d7ba14 100644 --- a/src/ECharts.php +++ b/src/ECharts.php @@ -50,6 +50,11 @@ class ECharts extends Widget */ public static $dist = self::DIST_COMMON; + /** + * @var array the extensions of echarts. + */ + public static $extensions = []; + /** * @var boolean whether resize the chart when the container size is changed. */ diff --git a/src/EChartsAsset.php b/src/EChartsAsset.php index 9b167c6..d04805d 100644 --- a/src/EChartsAsset.php +++ b/src/EChartsAsset.php @@ -40,6 +40,11 @@ public function init() default: throw new InvalidConfigException('The "dist" is not valid.'); } + + // Registers echarts extensions + foreach (ECharts::$extensions as $extension) { + $this->js[] = YII_DEBUG ? "extension/{$extension}.js" : "extension/{$extension}.min.js"; + } } parent::init();