Repository: zeppelin Updated Branches: refs/heads/branch-0.7 000900faf -> 4d80ec461
[ZEPPELIN-2234][BUG] Can't display the same chart again (branch-0.7) ### What is this PR for? Can't display the same chart again. I attached a screenshot. - this is the same fix with https://github.com/apache/zeppelin/pull/2110 - except refactoring PR - based on branch-0.7 and - CI failure might be related with https://github.com/apache/zeppelin/pull/2103 #### Implementation Details After https://github.com/apache/zeppelin/pull/2092, - result.html will draw chart every time since we use `ng-if` instead of `ng-show` - that means DOM is deleted, and created too - so we have to create visualization instance every time which requires a newly created DOM. ```js builtInViz.instance = new Visualization(loadedElem, config); // `loadedElem` is the newly created DOM. ``` ### What type of PR is it? [Bug Fix] ### Todos NONE ### What is the Jira issue? * Open an issue on Jira https://issues.apache.org/jira/browse/ZEPPELIN/ * Put link here, and add [ZEPPELIN-*Jira number*] in PR title, eg. [ZEPPELIN-533] ### How should this be tested? I attached a screenshot ### Screenshots (if appropriate) ##### Before: buggy  ##### After: fixed  ### Questions: * Does the licenses files need update? - NO * Is there breaking changes for older versions? - NO * Does this needs documentation? - NO Author: 1ambda <1am...@gmail.com> Closes #2114 from 1ambda/ZEPPELIN-2234/cant-display-same-chart-again-for-070 and squashes the following commits: 936123d [1ambda] fix: Retry until graph DOM is ready 475b532 [1ambda] fix: Reert #2092 for 0.7.0 Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/4d80ec46 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/4d80ec46 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/4d80ec46 Branch: refs/heads/branch-0.7 Commit: 4d80ec4610e55e3a8b2f0459600f5fb530168339 Parents: 000900f Author: 1ambda <1am...@gmail.com> Authored: Thu Mar 16 05:37:39 2017 +0900 Committer: Lee moon soo <m...@apache.org> Committed: Thu Mar 16 08:51:33 2017 -0700 ---------------------------------------------------------------------- .../src/app/notebook/paragraph/result/result.controller.js | 7 ++++++- zeppelin-web/src/app/notebook/paragraph/result/result.html | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4d80ec46/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js b/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js index 40f8248..9b95b40 100644 --- a/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js +++ b/zeppelin-web/src/app/notebook/paragraph/result/result.controller.js @@ -263,7 +263,12 @@ function ResultCtrl($scope, $rootScope, $route, $window, $routeParams, $location renderApp(app); } else { if (type === 'TABLE') { - $scope.renderGraph($scope.graphMode, refresh); + var retryRenderer = function() { + var elem = angular.element('#p' + $scope.id + '_graph'); + if (elem.length) { $scope.renderGraph($scope.graphMode, refresh); } + else { $timeout(retryRenderer, 10); } + }; + $timeout(retryRenderer); } else if (type === 'HTML') { renderHtml(); } else if (type === 'ANGULAR') { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4d80ec46/zeppelin-web/src/app/notebook/paragraph/result/result.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/notebook/paragraph/result/result.html b/zeppelin-web/src/app/notebook/paragraph/result/result.html index d76b8a4..df09c4d 100644 --- a/zeppelin-web/src/app/notebook/paragraph/result/result.html +++ b/zeppelin-web/src/app/notebook/paragraph/result/result.html @@ -28,10 +28,10 @@ limitations under the License. && config.graph.optionOpen && !asIframe && !viewOnly"> <div ng-repeat="viz in builtInTableDataVisualizationList track by $index" id="trsetting{{id}}_{{viz.id}}" - ng-if="graphMode == viz.id"></div> + ng-show="graphMode == viz.id"></div> <div ng-repeat="viz in builtInTableDataVisualizationList track by $index" id="vizsetting{{id}}_{{viz.id}}" - ng-if="graphMode == viz.id"></div> + ng-show="graphMode == viz.id"></div> </div> <!-- graph --> @@ -41,7 +41,7 @@ limitations under the License. > <div ng-repeat="viz in builtInTableDataVisualizationList track by $index" id="p{{id}}_{{viz.id}}" - ng-if="graphMode == viz.id"> + ng-show="graphMode == viz.id"> </div> </div>