refresh graph when paragraph height change. render correctly after paragraph type change

This commit is contained in:
Lee moon soo 2016-11-15 11:14:01 -08:00
parent 621c527f27
commit 6d1e2b68a0
2 changed files with 24 additions and 9 deletions

View file

@ -1054,11 +1054,30 @@
};
$timeout(retryRenderer);
} else if (refresh) {
console.log('Refresh data');
// when graph options or data are changed
builtInViz.instance.setConfig($scope.paragraph.config.graph);
builtInViz.instance.render(tableData);
var retryRenderer = function() {
var targetEl = angular.element('#p' + $scope.paragraph.id + '_' + type);
if (targetEl.length) {
targetEl.height(height);
builtInViz.instance.setConfig($scope.paragraph.config.graph);
builtInViz.instance.render(tableData);
} else {
$timeout(retryRenderer, 10);
}
};
$timeout(retryRenderer);
} else {
builtInViz.instance.activate();
var retryRenderer = function() {
var targetEl = angular.element('#p' + $scope.paragraph.id + '_' + type);
if (targetEl.length) {
targetEl.height(height);
builtInViz.instance.activate();
} else {
$timeout(retryRenderer, 10);
}
};
$timeout(retryRenderer);
}
}
}

View file

@ -51,11 +51,8 @@ zeppelin.Visualization.prototype.refresh = function() {
* Activate. invoked when visualization is selected
*/
zeppelin.Visualization.prototype.activate = function() {
console.log('active');
if (!this._active && this._resized) {
var self = this;
// give some time for element ready
setTimeout(function() {self.refresh();}, 300);
if (!this._active || this._resized) {
this.refresh();
this._resized = false;
}
this._active = true;
@ -65,7 +62,6 @@ zeppelin.Visualization.prototype.activate = function() {
* Activate. invoked when visualization is de selected
*/
zeppelin.Visualization.prototype.deactivate = function() {
console.log('deactive');
this._active = false;
};