livebook-dev / kino_vega_lite

Vega-Lite (graphics) integration for Livebook
Apache License 2.0
26 stars 8 forks source link

Dynamic vizualization flickering when clearing & updating values #27

Closed aedwardg closed 1 year ago

aedwardg commented 1 year ago

Is there any way to update values (rather than clear and push new values)?

When push data to the VegaLite graph that needs to change (rather than build on top of itself), I see a flickering in the graphic. I believe this is due to having to call Kino.VegaLite.clear before pushing the new values.

If this is me just using it wrong, please let me know 😅

Below is an example of a visualization of for Advent of Code 2022 Day 5:

https://user-images.githubusercontent.com/44326005/205779490-2acdce21-b98f-4c5d-819d-fb18d934854f.mov

Source code: https://github.com/aedwardg/advent-of-code-elixir/blob/main/2022/day05/viz.livemd

jonatanklosko commented 1 year ago

Hey @aedwardg! When using :window you don't need to do Kino.VegaLite.clear. If the graph has 9 points, then you push new 9 points with the window of 9, this is effectively a replace operation. However, I've just checked and there was a bug in that edge case, such that the old points wouldn't be removed, and I assume that's why you added the clear operation? Please try the version from main using {:kino_vega_lite, github: "livebook-dev/kino_vega_lite"} and let me know if it works without clear now :)

aedwardg commented 1 year ago

@jonatanklosko that works exactly as expected now. Thank you! I'm always impressed by how quick and responsive the Livebook team is 🙂

jonatanklosko commented 1 year ago

Awesome, thanks for checking!