Constant, fixed width on x-Axis with streaming data

Hello there -

My question is: is it possible to maintain a constant width (i.e. stop auto-ranging) for a real-time graph. Think of an EKG. I know variants of this question have been asked before, with pointers given to the OHLC demo. That demo, doesn’t quite answer my question because if you watch the graph it starts displaying in the decimal range, then goes to every 1 unit, then every 2 units, then 5, 10, etc. I desire a fixed window that slides by 1 unit for every 1 second of time.

I tried setting the range, as below, but my range keeps jumping backwards … it’s not monotonic, example below:

x = [datetime.datetime.now()]
y = np.random.randint(-10, 10, 1)

sourcex = ColumnDataSource(data={'x':x, 'y':y})
plot = figure(x_axis_type='datetime', y_range=(-10, 10))

plot.circle(x=‘x’, y=‘y’, source=sourcex)
plot.xaxis[0].formatter = DatetimeTickFormatter(seconds=["%M:%S"], minutes=["%M:%S"], minsec=["%M:%S"], hours=["%M:%S"])
plot.x_range.start = int(time.mktime(base.timetuple()) * 1000)
plot.x_range.end = plot.x_range.start + 30000 # create a 30 second wide initial view window

def callback():
base = [datetime.datetime.now()]
y = np.random.randint(-10, 10, 1)
new_data = { ‘x’:base, ‘y’:y}
plot.x_range.start += 1000
plot.x_range.end += 1000 # slide both start and end of range by 1 second
sourcex.stream(new_data)
print("{}:{}".format(plot.x_range.start, plot.x_range.end)) # here we see range jumping forwards (good) and backwards (bad)


doc.add_root(plot)

doc.add_periodic_callback(callbackx, 1000)

Thanks for any help and/or pointers! I confess I’m not fully groking follow and follow_interval.