Streaming Data with static X data


I’m looking at using Bokeh for an application with live streaming plots; I’m currently working directly with the flot javascript library. I’ve worked through and fiddled with the Bokeh tutorials for streaming data from Flask and am really encouraged by the possibility.

The app will update data every 100ms, always showing the most recent 500 data samples and appending new data to the right side of the plot (AjaxDataSource stream in append mode). This all works great based on an example in flask_bokeh_ajax. The issue I’m having is finding a way to not update the x-axis data. Ideally, I’d like the x-axis to show the age of a sample (-50 to 0 seconds) , not an absolute time that it was collected or an arbitrary index number. The only way I’ve found to do this is to use “replace” mode for AjaxDataSource, and this doesn’t work well given the size and update rate of the data. Is there a way to only update the Y-axis data and keep the x-axis static?

An example of what I’m trying to do can be found on this [completely unrelated] page:

I’m probably going to write some type of custom extension anyway to handle the socket-io events I intend to use for my data stream in the final app but don’t want to re-invent this capability if it already exists.

Thanks for a great library.


I can’t think of any way to do exactly this with existing Bokeh models. If you could pre-fill the CDS to “full” capacity up front, then you could potentially just leave any “x” coordinate out of the Ajax endpoint update. I have for a long time wanted to add the option for a CustomJS adapter property to AjaxDataSource that would allow users to supply a small bit of JS code that adapts the Ajax response to the Bokeh CDS format. That would be useful in and of itself, but would also help in this situation, but I have not had an opportunity to work on it. If you are interested in diving in to BokehJS already, please consider making a PR for this feature.


Thanks for the reply. I’ll take a look and see if I can figure out how to implement this. If I do, I’ll definitely submit a PR.


Great! Happy to answer any questions that come up