From c6a67eb720cc706121fb1427983e4f35c7465a0c Mon Sep 17 00:00:00 2001 From: amelkikh Date: Thu, 11 Aug 2016 11:19:33 +0500 Subject: [PATCH 1/3] Added plugin for point labels --- .gitignore | 1 + JqPlot.php | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/JqPlot.php b/JqPlot.php index 351f8e7..a8e773c 100644 --- a/JqPlot.php +++ b/JqPlot.php @@ -150,5 +150,7 @@ public function registerRendererJsFile($renderer) if (!in_array($url, Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js)) { Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js[] = $url; } + + Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js[] = 'plugins/jqplot.pointLabels.js'; } } From 5d5af26c324debbe11161487301d75c2bf9bff61 Mon Sep 17 00:00:00 2001 From: amelkikh Date: Thu, 11 Aug 2016 11:31:12 +0500 Subject: [PATCH 2/3] Recursively check for pointLabel option --- JqPlot.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/JqPlot.php b/JqPlot.php index a8e773c..e71fe54 100644 --- a/JqPlot.php +++ b/JqPlot.php @@ -119,6 +119,8 @@ public function registerRenderersRecursively($data) foreach ($data as $k => $v) { if ($k == 'renderer' || $k == 'tickRenderer') { $this->registerRendererJsFile($v); + } elseif ($k == 'pointLabels' && isset($v['show']) && (boolean)$v['show']) { + Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js[] = 'plugins/jqplot.pointLabels.js'; } elseif (is_array($v)) { $this->registerRenderersRecursively($v); } @@ -150,7 +152,5 @@ public function registerRendererJsFile($renderer) if (!in_array($url, Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js)) { Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js[] = $url; } - - Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js[] = 'plugins/jqplot.pointLabels.js'; } } From 687ced1e09973295e6c9b796fad9857e2bbe7cba Mon Sep 17 00:00:00 2001 From: amelkikh Date: Thu, 11 Aug 2016 11:38:53 +0500 Subject: [PATCH 3/3] Rename function registerRenderersRecursively to registerDependenciesRecursively --- JqPlot.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/JqPlot.php b/JqPlot.php index e71fe54..3c36248 100644 --- a/JqPlot.php +++ b/JqPlot.php @@ -101,7 +101,7 @@ protected function registerJqPlotWidget() */ protected function registerJqPlotClientOptions($id) { - $this->registerRenderersRecursively($this->clientOptions); + $this->registerDependenciesRecursively($this->clientOptions); $data = Json::htmlEncode($this->data); $options = !empty($this->clientOptions) ? Json::htmlEncode($this->clientOptions) : '{}'; @@ -113,7 +113,7 @@ protected function registerJqPlotClientOptions($id) * Find renderers and register their JS plugins * @param array $data */ - public function registerRenderersRecursively($data) + public function registerDependenciesRecursively($data) { // Looking for renderers foreach ($data as $k => $v) { @@ -122,7 +122,7 @@ public function registerRenderersRecursively($data) } elseif ($k == 'pointLabels' && isset($v['show']) && (boolean)$v['show']) { Yii::$app->assetManager->bundles[JqPlotAsset::className()]->js[] = 'plugins/jqplot.pointLabels.js'; } elseif (is_array($v)) { - $this->registerRenderersRecursively($v); + $this->registerDependenciesRecursively($v); } }