mirror of
https://github.com/nasa/openmct.git
synced 2025-06-02 23:50:49 +00:00
[Plot] Wait for width before loading (#1975)
Plot waits for element to have width before loading. Otherwise, it may make a minmax request with an invalid size parameter. Fixes https://github.com/nasa/openmct/issues/1974
This commit is contained in:
parent
1a23f2b390
commit
fa7298a752
@ -82,6 +82,10 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
PlotController.prototype.loadSeriesData = function (series) {
|
PlotController.prototype.loadSeriesData = function (series) {
|
||||||
|
if (this.$element[0].offsetWidth === 0) {
|
||||||
|
this.scheduleLoad(series);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.startLoading();
|
this.startLoading();
|
||||||
var options = {
|
var options = {
|
||||||
size: this.$element[0].offsetWidth,
|
size: this.$element[0].offsetWidth,
|
||||||
@ -92,6 +96,26 @@ define([
|
|||||||
.then(this.stopLoading.bind(this));
|
.then(this.stopLoading.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PlotController.prototype.scheduleLoad = function (series) {
|
||||||
|
if (!this.scheduledLoads) {
|
||||||
|
this.startLoading();
|
||||||
|
this.scheduledLoads = [];
|
||||||
|
this.checkForSize = setInterval(function () {
|
||||||
|
if (this.$element[0].offsetWidth === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.stopLoading();
|
||||||
|
this.scheduledLoads.forEach(this.loadSeriesData, this);
|
||||||
|
delete this.scheduledLoads;
|
||||||
|
clearInterval(this.checkForSize);
|
||||||
|
delete this.checkForSize;
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
if (this.scheduledLoads.indexOf(series) === -1) {
|
||||||
|
this.scheduledLoads.push(series);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
PlotController.prototype.addSeries = function (series) {
|
PlotController.prototype.addSeries = function (series) {
|
||||||
this.listenTo(series, 'change:yKey', function () {
|
this.listenTo(series, 'change:yKey', function () {
|
||||||
this.loadSeriesData(series);
|
this.loadSeriesData(series);
|
||||||
@ -126,6 +150,10 @@ define([
|
|||||||
PlotController.prototype.destroy = function () {
|
PlotController.prototype.destroy = function () {
|
||||||
configStore.untrack(this.config.id);
|
configStore.untrack(this.config.id);
|
||||||
this.stopListening();
|
this.stopListening();
|
||||||
|
if (this.checkForSize) {
|
||||||
|
clearInterval(this.checkForSize);
|
||||||
|
delete this.checkForSize;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PlotController.prototype.loadMoreData = function (range, purge) {
|
PlotController.prototype.loadMoreData = function (range, purge) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user