Black Lives Matter. Please consider donating to Black Girls Code today.

How to trim the domain / number of points when using extendData

Hi, I recently updated my live data visualization app to use extendData instead of updating the entire figure every tick. However, I only want to be showing the last n seconds of data in the plot. My current theorized solution is to run a slower interval that removes the older data every ~10 seconds, but this is not ideal and will result in chunks of the data being removed at once rather than the smooth scrolling effect I want. Any ideas? Thanks!

Update: I found a forum thread that explained that extendTraces for plotly takes a third argument, max number of points. I decided to check if extendData has the same optional third argument, and it does. Eg.


new_data = (dict(
), [0], n)

This should really be documented / added to the examples!