Hi all,
Is it possible to stream into a varea_stack with a new CDS that may contain more/less/only some of the same stackers?
Essentially I’m stacking the rate of traffic from particular IP addresses per-minute but if traffic from that IP address disappears, or a new IP address appears, then the updated source would be different in column length to the original and at present it seems as if this would give me the error: ValueError: Must stream updates to all existing columns on Bokeh 2.4.3.
A minimal example of an initial data set being plotted is as follows:
import pandas as pd
from bokeh.plotting import figure, output_file, show
from bokeh.models import ColumnDataSource
from bokeh.palettes import viridis
data = {
"datetime": ["2022-06-08 12:00:00", "2022-06-08 12:01:00", "2022-06-08 12:02:00","2022-06-08 12:00:00", "2022-06-08 12:01:00", "2022-06-08 12:02:00"],
"BITS": [100, 0, 100, 200,200,200],
"SRC_IP": ["192.168.1.1","192.168.1.1","192.168.1.1","192.168.2.1","192.168.2.1","192.168.2.1"]
}
finalDf = pd.DataFrame.from_dict(data)
print(finalDf)
finalDf = finalDf.pivot(index="datetime", columns="SRC_IP", values="BITS").fillna(0)
timestamps = finalDf.index.tolist()
src_ips = finalDf.columns.tolist()
color = viridis(len(src_ips))
q = figure(x_range=timestamps)
source = ColumnDataSource(finalDf)
q.varea_stack(src_ips, x="datetime", source=finalDf, color=color, legend_label=src_ips)
show(q)
I would then ideally want to stream in new data where there is also data from a new IP address:
data = {
"datetime": ["2022-06-08 12:03:00", "2022-06-08 12:04:00", "2022-06-08 12:03:00", "2022-06-08 12:04:00", "2022-06-08 12:03:00", "2022-06-08 12:04:00"],
"BITS": [300, 100, 400, 100, 600, 400],
"SRC_IP": ["192.168.1.1","192.168.1.1","192.168.1.1","192.168.2.1","192.168.2.1","192.168.2.1","192.168.3.1","192.168.3.1"]
}
or stream in data where for instance one or more of the IP addresses stops sending data.
If it’s possible I’ll keep trying but at present I can’t find a suitable simple working example to give me a hint in the right direction.
Kind Regards,
Carl