fixing charts to not render twice

This commit is contained in:
ppisljar 2016-09-20 10:55:55 +02:00
parent cd4e1dc7de
commit f7f0f12439
3 changed files with 12 additions and 1 deletions

View file

@ -182,6 +182,10 @@ export default function ResizeCheckerFactory(Private, Notifier) {
}, ms));
};
ResizeChecker.prototype.stopSchedule = function () {
clearTimeout(this._timerId);
};
/**
* Signal that the ResizeChecker should shutdown.
*

View file

@ -64,8 +64,12 @@ export default function VisFactory(Private) {
uiState.on('change', this._uiStateChangeHandler = () => this.render(this.data, this.uiState));
}
this.resizeChecker.stopSchedule();
this.handler = handlerTypes[chartType](this) || handlerTypes.column(this);
this._runOnHandler('render');
this.resizeChecker.saveSize();
this.resizeChecker.saveDirty(false);
this.resizeChecker.continueSchedule();
};
/**

View file

@ -46,7 +46,10 @@ module.exports = function VislibRenderbotFactory(Private) {
VislibRenderbot.prototype.buildChartData = buildChartData;
VislibRenderbot.prototype.render = function (esResponse) {
this.chartData = this.buildChartData(esResponse);
this.vislibVis.render(this.chartData, this.uiState);
// to allow legend to render first
setTimeout(() => {
this.vislibVis.render(this.chartData, this.uiState);
});
};
VislibRenderbot.prototype.destroy = function () {