Skip to content

Commit

Permalink
Merge pull request #49 from brown-ccv/fix-storybook-chart
Browse files Browse the repository at this point in the history
fix: handle non-existant div in storybook
  • Loading branch information
mcmcgrath13 authored Jan 21, 2021
2 parents a2e42a7 + 3fcf5d4 commit 7b578c6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/mixins/vega-base-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,21 @@ const vegaBaseMixin = {
parentElement: null,
};
},
mounted() {
created() {
// add random number to id to ensure uniqueness - important for storybook
this.fullId = this.id + Math.floor(Math.random() * Math.floor(1000));

},
mounted() {
this.$nextTick(() => {
const el = document.querySelector('#' + this.fullId);
this.parentElement = el.parentElement;
if (el) {
this.parentElement = el.parentElement;

this.updatePlot();
this.updatePlot();

this.resizeObserver = new ResizeObserver(this.resizePlot);
this.resizeObserver.observe(this.parentElement);
this.resizeObserver = new ResizeObserver(this.resizePlot);
this.resizeObserver.observe(this.parentElement);
}
});
},
beforeDestory() {
Expand Down

0 comments on commit 7b578c6

Please sign in to comment.