In my current setup with bokeh server I dynamically append plots to a layout. This works but it flickers and temporarily disarranges all the plots so I think all plots are redrawn (or even rebuilt) every time a child is appended to the layout. Is it possible to avoid this flickering and decelarating rebuild?
See this example that demonstrates what I mean:
import numpy as np
from tornado.ioloop import IOLoop
from bokeh.application.handlers import FunctionHandler
from bokeh.application import Application
from bokeh.plotting import figure
from bokeh.server.server import Server
from bokeh.models.layouts import VBox
io_loop = IOLoop.current()
layout = VBox()
def modify_doc(doc):
doc.add_root(layout)
doc.add_periodic_callback(add_plot, 5000)
def add_plot():
x = np.linspace(0, 4 * np.pi, 1000)
y = np.sin(x)
plot2 = figure(y_range=(-1.2, 1.2))
plot2.line(x, y, line_width=2, legend="x")
layout.children.append(plot2)
bokeh_app = Application(FunctionHandler(modify_doc))
server = Server({'/': bokeh_app}, io_loop=io_loop)
server.start()
if __name__ == '__main__':
print('Opening Bokeh application on http://localhost:5006/')
io_loop.add_callback(server.show, "/")
io_loop.start()
At present, probably not. Global coordinates are computed for all objects in a layout, and adding a new item means re-computing the layout for everything (which means re-drawing). There is an open issue to allow individual elements from a Bokeh server app to be templated individually (i.e they don't share layout state with other objects) which would probably solve the problem at the expense of having to do something a little more involved than layout.children.append to add new plots to the page.
FYI this example is broken in master. I've created an issue for the regression
In my current setup with bokeh server I dynamically append plots to a layout. This works but it flickers and temporarily disarranges all the plots so I think all plots are redrawn (or even rebuilt) every time a child is appended to the layout. Is it possible to avoid this flickering and decelarating rebuild?
See this example that demonstrates what I mean:
import numpy as np
from tornado.ioloop import IOLoop
from bokeh.application.handlers import FunctionHandler
from bokeh.application import Application
from bokeh.plotting import figure
from bokeh.server.server import Server
from bokeh.models.layouts import VBox