Check for null plot wrapper on plot resize (#5960)

* check for null plot wrapper first

* make code clearer with short circuit up front
This commit is contained in:
Scott Bell 2022-11-08 16:11:46 -08:00 committed by GitHub
parent a2d8b13204
commit fabfecdb3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1192,11 +1192,15 @@ export default {
this.$emit('statusUpdated', status);
},
handleWindowResize() {
const newOffsetWidth = this.$parent.$refs.plotWrapper.offsetWidth;
const { plotWrapper } = this.$parent.$refs;
if (!plotWrapper) {
return;
}
const newOffsetWidth = plotWrapper.offsetWidth;
//we ignore when width gets smaller
const offsetChange = newOffsetWidth - this.offsetWidth;
if (this.$parent.$refs.plotWrapper
&& offsetChange > OFFSET_THRESHOLD) {
if (offsetChange > OFFSET_THRESHOLD) {
this.offsetWidth = newOffsetWidth;
this.config.series.models.forEach(this.loadSeriesData, this);
}