This example shows an interactive bokeh plots communicating to a live REST service with a bokeh AjaxDataSource to show 15 years of AAPL stock prices down to the minute. When portions of data are selected an Javascript Callback is fired and communicates the new bounds to the rest service that downsamples the data accordingly to the new interval.
NOTE: The prices data are taken from yahoo finance free data. As this service only provides day prices the data of the lower minute level of detail is being simulated.
In [2]:
#import custom_stocks_panel as csp
from bokeh.io import VBox, output_notebook
from bokeh.io import show
In [2]:
output_notebook()
In [3]:
theme_name = 'dark'
p = csp.create_main_plot(theme_name)
selection_plot = csp.create_selection_plot(p, theme_name, ajax=False)
box = VBox(p, selection_plot)
In [4]:
def update_theme(theme_name='default'):
objects = {'main_plot': p, 'selection_plot': selection_plot}
theme = load_from_yaml("%s.yaml" % theme_name)
apply_theme(theme, objects)
Use the lower smaller plot to select regions of data to show on the upper plot. The upper plot will update it's ranges to match the selected interval.
Press ESC to unselect the region.
NOTE: Zooming and reseting on the upper plot will only take effect locally and won't update the ranges of the lower selection plot. To reset the selection press ESC as mentioned above.
In [5]:
show(box)
In [ ]: