-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hidden scatterplot instance throws an error when shown interactively #20
Comments
Thanks for providing a demo. I'll take a look. By the way, is this essentially the same as #17? |
Yes, i think it is the same issue. |
I am not sure why you decided to use
When I replace I'll try to find out why but I also suspect it's because the canvas element is |
It seems to be related to the fact that canvas element does not have a size. Everything works also fine when I use It appears as if |
I was trying to replicate behavior of Vue's In my application i have multiple tabs with separate Plots have zero width and height when hidden due to UPDATE: you are right about
and i still have this problem with |
Here is a short screencast demonstrating the issue. As you can see, the first plot (with cell background image) is updated properly according to cell mask after i select cells on the PCA plot, but any mouse movement (zoom/panning) is throwing an error (can be seen on console panel): https://drive.google.com/file/d/1HfXmnEAiiVFT61rKoUMlgBZiQzCIq2Yo/view |
Okay, the issue is that you need to call E.g.: canvas2.hidden = false;
window.requestAnimationFrame(() => {
const { width, height } = canvas2.getBoundingClientRect();
// Second scatterplot
scatterplots[1].set({ width, height });
}); Besides, another simple fix is to manually set a proper width and height before hiding the canvas. E.g., the following will work fine: window.requestAnimationFrame(() => {
const { width, height } = canvas2.getBoundingClientRect();
canvas2.width = width * window.devicePixelRatio;
canvas2.height = height * window.devicePixelRatio;
canvas2.hidden = true;
}); The error was caused by I'll update the |
Let me know if this solves your issue. |
Thank you for the suggestion, it really worked. I found out that Vuetify has a very useful directive onIntersect(entries, observer, isIntersecting) {
if (isIntersecting) {
const canvas = this.$refs.canvas as Element;
const { width, height } = canvas.getBoundingClientRect();
this.scatterplot.set({ width, height });
}
} And issue is gone! Thanks again for your time and efforts. |
Awesome! I am glad it's working now. I added a note to the README.md to give people a hint. |
I could reproduce the issue #17. The problem occurs when plot is created, but hidden (in my case i created multiple plots in different Vuetify tabs). Probably this is due to
canvas.getBoundingClientRect()
returning (0, 0) somewhere inregl-scatterplot
code in such cases.I created a small demo to show this behavior. Second canvas is hidden, and then should be displayed when one makes a selection on the first canvas. But instead it'll throw errors like the following when mouse is over second canvas:
Sorry if the demo is a bit awkward.
https://github.com/plankter/regl-scatterplot-two-instances
The text was updated successfully, but these errors were encountered: