From ae1a4bcc6af6a5551c46e4bc5a7675c04ebd222d Mon Sep 17 00:00:00 2001 From: Shefali Joshi Date: Fri, 28 May 2021 11:44:56 -0700 Subject: [PATCH] A change in the parent container's size for plots re-requests telemetry (#3890) * Use resize obeserver to detect a change in the parent container's size for plots and re-request telemetry --- src/plugins/plot/MctPlot.vue | 13 +++++++++++++ src/plugins/plot/pluginSpec.js | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/src/plugins/plot/MctPlot.vue b/src/plugins/plot/MctPlot.vue index 0459840b33..9f26ddcb84 100644 --- a/src/plugins/plot/MctPlot.vue +++ b/src/plugins/plot/MctPlot.vue @@ -159,6 +159,7 @@ import MctTicks from "./MctTicks.vue"; import MctChart from "./chart/MctChart.vue"; import XAxis from "./axis/XAxis.vue"; import YAxis from "./axis/YAxis.vue"; +import _ from "lodash"; export default { components: { @@ -496,6 +497,10 @@ export default { }, initialize() { + _.debounce(this.handleWindowResize, 400); + this.plotContainerResizeObserver = new ResizeObserver(this.handleWindowResize); + this.plotContainerResizeObserver.observe(this.$parent.$refs.plotWrapper); + // Setup canvas etc. this.xScale = new LinearScale(this.config.xAxis.get('displayRange')); this.yScale = new LinearScale(this.config.yAxis.get('displayRange')); @@ -999,12 +1004,20 @@ export default { this.removeStatusListener(); } + this.plotContainerResizeObserver.disconnect(); + this.openmct.time.off('clock', this.updateRealTime); this.openmct.time.off('bounds', this.updateDisplayBounds); this.openmct.objectViews.off('clearData', this.clearData); }, updateStatus(status) { this.$emit('statusUpdated', status); + }, + handleWindowResize() { + if (this.offsetWidth !== this.$parent.$refs.plotWrapper.offsetWidth) { + this.offsetWidth = this.$parent.$refs.plotWrapper.offsetWidth; + this.config.series.models.forEach(this.loadSeriesData, this); + } } } }; diff --git a/src/plugins/plot/pluginSpec.js b/src/plugins/plot/pluginSpec.js index 9d8d37f44b..324f95cdd2 100644 --- a/src/plugins/plot/pluginSpec.js +++ b/src/plugins/plot/pluginSpec.js @@ -99,6 +99,11 @@ describe("the plugin", function () { element.appendChild(child); document.body.appendChild(element); + spyOn(window, 'ResizeObserver').and.returnValue({ + observe() {}, + disconnect() {} + }); + openmct.time.timeSystem("utc", { start: 0, end: 4