megaplot
megaplot copied to clipboard
Better handling of invisible plots when container width or height are 0
On LIT, we're using MegaPlot to replace the Scalars module. I noticed that the div.scatterplot-container into which I render a MegaPlot scene in the firstUpdated() lifecycle hook has a width of 0 (width: 100%; in CSS, but LIT's widget rendering code doesn't set the parent's width until later). This resulted in a <canvas> being added to the screen, but all of the content was effectively invisible.
Could MegaPlot:
-
throwsome sort of error when the width or height of the container into which it's appending the<canvas>are 0? - Wait until the width and height of the container are non-zero (e.g., using a ResizeObserver) before rending the scene?
Is this still an issue? I believe the behavior around zero-sized containers has been improved, but I don't recall if it solved exactly this case.