mirror of
https://github.com/elastic/kibana.git
synced 2025-04-22 17:04:01 -04:00
Backport PR #8371
--------- **Commit 1:** fixing charts to not render twice * Original sha:f7f0f12439
* Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-20T08:55:55Z **Commit 2:** fixing tests * Original sha:40234e8e41
* Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-21T07:21:01Z **Commit 3:** fixing based on Spencers comments * Original sha:cdad7724bc
* Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-21T19:41:57Z
This commit is contained in:
parent
9876c88fa8
commit
61d487c724
4 changed files with 24 additions and 6 deletions
|
@ -184,6 +184,10 @@ export default function ResizeCheckerFactory(Private, Notifier, $rootScope) {
|
||||||
}, ms));
|
}, ms));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ResizeChecker.prototype.stopSchedule = function () {
|
||||||
|
clearTimeout(this._timerId);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signal that the ResizeChecker should shutdown.
|
* Signal that the ResizeChecker should shutdown.
|
||||||
*
|
*
|
||||||
|
|
|
@ -68,7 +68,7 @@ export default function VisFactory(Private) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handler = handlerTypes[chartType](this) || handlerTypes.column(this);
|
this.handler = handlerTypes[chartType](this) || handlerTypes.column(this);
|
||||||
this._runOnHandler('render');
|
this._runWithoutResizeChecker('render');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,6 +89,14 @@ export default function VisFactory(Private) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Vis.prototype._runWithoutResizeChecker = function (method) {
|
||||||
|
this.resizeChecker.stopSchedule();
|
||||||
|
this._runOnHandler(method);
|
||||||
|
this.resizeChecker.saveSize();
|
||||||
|
this.resizeChecker.saveDirty(false);
|
||||||
|
this.resizeChecker.continueSchedule();
|
||||||
|
};
|
||||||
|
|
||||||
Vis.prototype._runOnHandler = function (method) {
|
Vis.prototype._runOnHandler = function (method) {
|
||||||
try {
|
try {
|
||||||
this.handler[method]();
|
this.handler[method]();
|
||||||
|
|
|
@ -134,10 +134,11 @@ describe('renderbot', function exportWrapper() {
|
||||||
let buildStub = sinon.stub(renderbot, 'buildChartData', _.constant(football));
|
let buildStub = sinon.stub(renderbot, 'buildChartData', _.constant(football));
|
||||||
let renderStub = sinon.stub(renderbot.vislibVis, 'render');
|
let renderStub = sinon.stub(renderbot.vislibVis, 'render');
|
||||||
|
|
||||||
renderbot.render('flat data', persistedState);
|
return renderbot.render('flat data', persistedState).then(() => {
|
||||||
expect(renderStub.callCount).to.be(1);
|
expect(renderStub.callCount).to.be(1);
|
||||||
expect(buildStub.callCount).to.be(1);
|
expect(buildStub.callCount).to.be(1);
|
||||||
expect(renderStub.firstCall.args[0]).to.be(football);
|
expect(renderStub.firstCall.args[0]).to.be(football);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,12 @@ module.exports = function VislibRenderbotFactory(Private) {
|
||||||
VislibRenderbot.prototype.buildChartData = buildChartData;
|
VislibRenderbot.prototype.buildChartData = buildChartData;
|
||||||
VislibRenderbot.prototype.render = function (esResponse) {
|
VislibRenderbot.prototype.render = function (esResponse) {
|
||||||
this.chartData = this.buildChartData(esResponse);
|
this.chartData = this.buildChartData(esResponse);
|
||||||
this.vislibVis.render(this.chartData, this.uiState);
|
// to allow legend to render first (wait for angular digest cycle to complete)
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve(this.vislibVis.render(this.chartData, this.uiState));
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
VislibRenderbot.prototype.destroy = function () {
|
VislibRenderbot.prototype.destroy = function () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue