
Hi I was able to get my data to stream to a bokeh server but I’m noticing that the xaxis does not dynamically update with it.
Here’s my current test code:
from random import randint
from bokeh.layouts import column
from bokeh.models import Button,ColumnDataSource,FactorRange
from bokeh.plotting import figure, curdoc
# create a plot and style its properties
p = figure(x_range=(0,250), y_range=(9230, 9240), toolbar_location=None)
ds = ColumnDataSource(data=dict(count=[], l4=[]))
# render scatter plot
r = p.circle(x='count', y='l4', source=ds)
i = 0
# create a callback that will get "l4" data for the next count
def button_callback():
curdoc().add_periodic_callback(update, 20)
def update():
global i
new_data = stream_l4_data()
i = i+1
ds.stream(new_data)
def stream_l4_data() -> dict:
global i
return dict(count=[i+1], l4=[randint(9232, 9235)])
# add a button widget and configure with the call back
button = Button(label="Start")
button.on_click(button_callback)
# put the button and plot in a layout and add to the document
curdoc().add_root(column(button, p))
I’m aware I have x_range=(0, 250) and that its limiting my graph, but I haven’t been found anything in the forums or the documentation that allows me to grow the xaxis dynamically as more data is put in. The width will stay the same, so I can possibly shrink the tick mark spacing as time goes on, but the beginning mark of the x axis should be 0 and the last mark should be the final count of how much data has passed though (0 based).
