Repository navigation
Description
For a live dashboard I would like to go through historic data but also see the currently incoming data.
Maybe I misunderstand register_source(*args, cache=False) but I thought that if my data is not static and I specify cache=False that this is taken into account. #39 is concerned with the other case, that I state that I want to cache but the data changes anyway.
Here, it appears that the cache flag is not enough for changing data: In the small example below the plots never shows more than the initial data, only if I re-register at each update new data is incorporated into the plots.
from datetime import timedelta
import threading
import time
import numpy as np
import polars as pl
from flexviz import Dashboard, register_source
SOURCE = "value"
STEP = timedelta(seconds=1)
n = 10
value = np.sin(np.arange(n) / 5e4) + np.random.default_rng(0).standard_normal(n) * 0.05
ts = pl.datetime(2024, 1, 1) + pl.duration(seconds=pl.int_range(n) * 1)
df = pl.select(timestamp=ts, value=pl.Series(value))
def refresh():
rng = np.random.default_rng(1)
i = n
while True:
time.sleep(1)
point = pl.DataFrame({
"timestamp": [df["timestamp"][-1] + STEP],
"value": [float(np.sin(i / 5e4) + rng.standard_normal() * 0.05)],
})
df.extend(point) # one-row append
# this seems to be required to push new data to the dashboard:
# register_source(SOURCE, df, cache=False)
print(f"len(df) = {len(df)}")
i += 1
threading.Thread(target=refresh, daemon=True).start()
dash = Dashboard(df, cache=False) # caching of df disabled
dash.add_figure(title="value").add_line(x="timestamp", y="value", n_points=2000)
dash.add_figure(title="distribution").add_histogram(x="value", bins=60)
register_source(SOURCE, df, cache=False)
dash.show(source_name=SOURCE, cols=1, port=8000)Is there a way to add or stream new data into flexviz without completely sending all existing data? Ideally with a shifting/adapting time axis like other dashboard systems.
Activity
jvdd commentedon Oct 9, 2026
Hi @asteppke, thanks for the clear report and the runnable example. I can reproduce it.
TLDR; this is how polars handles references to a frame.
What happens
register_sourcewraps your DataFrame withdf.lazy(). In Polars that is a snapshot. Changes you make todfin place after that (extend,vstack(in_place=True)) are not seen. You can check it without FlexViz:cache=Falseonly switches off FlexViz's response caches. It does not make FlexViz read the DataFrame again. Our docs do not say this (and I understand your confusion here), so we will fix the docs.The page also never polls the server. Even with fresh data on the server, an open page only shows it after you reload or interact with it (zoom, pan, clear a selection).
What works today
Re-registering on each update, as you found, is the supported way:
About your question on sending all the data: re-registering does not send anything to the browser, and it copies nothing. It only swaps the snapshot inside the server process. The browser only ever gets the downsampled output: at most
n_pointsper line and one count per bin for the histogram. Then reload the page or zoom to see the new data.-> so the browser is fully unaware of the changed / swapped source.
-> there is also quite some recompute here (that theoretically can be avoided).
Real live mode
FlexViz has no live or streaming mode yet. We did build a prototype before the public release (but did not further pursue it since streaming had little traction when we were doing our outreach). It had:
handle.append(batch)) with checks on time orderBefore we decide how (and if) to bring it back, it would help a lot to know your use case:
Thanks again, this is very useful input.
asteppke commentedon Oct 12, 2026
Thank you @jvdd for your insightful comments! I was not aware of the
df.lazy()framing and it is good to know that re-registering does not lead to a full copy & send cycle.Regarding the streaming mode, that would be exactly what I was looking for, a live and locked mode that can be switched between.
Our use case comes from machine data, both measurements and diagnostic information. For your questions specifically let me try to answer them briefly:
Thanks again for looking into this!
jvdd commentedon Oct 13, 2026
Thanks @asteppke! We built a first version of streaming on the feat/streaming branch (draft PR #163, so the API can still change).
What it does
register_stream(name, df, order_by="timestamp", window=...)registers data that grows.stream.append(batch)adds rows, from any thread (thus no re-registering needed anymore).Limitations of this first version
=> the retention + full recompute are still 2 things we should optimize / look into (before the PR can merge in main)
Questions
Some questions that help us decide what to build next:
Thanks again, your input is very useful!
asteppke commentedon Oct 15, 2026
Thank you @jvdd!
I tested the draft PR #163 and it works very nice already with some test data.
Concretely to your questions:
When using the interface in the current state one wish would be that when I change the time axis window, e.g. by zooming, that switching to live view slides as rows arrive without the need to zoom out.