🏠 back to Observable

Plot update pattern?

I am really enjoying the new Plot library, thanks!

Several of the hand-coded plots I would like to migrate use the update pattern from the Bar Chart Race with Scrubber example, which allows static (and potentially expensive) elements to be drawn once by exposing an update method to draw the dynamic content.

Is there a similar pattern that works with the Plot library? Here is a simple example showing the wrong way to do this, by redrawing the whole plot at each update:

Thank you!

It is possible to expose an update function from the mark, that you can then call to update the mark. See the changes in Plot Update Pattern / Fil / Observable ; but as you can see in that example, it’s definitely not easy, in particular because we have to struggle a bit to attach the function to the plot (with an async function and the search of the svg parent element).

The issue is discussed at Incremental rendering for performance? · Issue #328 · observablehq/plot · GitHub