Here are the examples of the python api bokeh.models.sources.AjaxDataSource taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
0
View Source File : dashboard.py
License : BSD 3-Clause "New" or "Revised" License
Project Creator : jcrist
License : BSD 3-Clause "New" or "Revised" License
Project Creator : jcrist
def build_html():
"""Build the html, to be served by IndexHandler"""
source = AjaxDataSource(data_url='./data',
polling_interval=INTERVAL,
method='GET')
# OHLC plot
p = figure(plot_height=400,
title='OHLC',
sizing_mode='scale_width',
tools="xpan,xwheel_zoom,xbox_zoom,reset",
x_axis_type=None,
y_axis_location="right",
y_axis_label="Price ($)")
p.x_range.follow = "end"
p.x_range.follow_interval = 100
p.x_range.range_padding = 0
p.line(x='time', y='average', alpha=0.25, line_width=3, color='black',
source=source)
p.line(x='time', y='ma', alpha=0.8, line_width=2, color='steelblue',
source=source)
p.segment(x0='time', y0='low', x1='time', y1='high', line_width=2,
color='black', source=source)
p.segment(x0='time', y0='open', x1='time', y1='close', line_width=8,
color='color', source=source, alpha=0.8)
# MACD plot
p2 = figure(plot_height=200,
title='MACD',
sizing_mode='scale_width',
x_range=p.x_range,
x_axis_label='Time (s)',
tools="xpan,xwheel_zoom,xbox_zoom,reset",
y_axis_location="right")
p2.line(x='time', y='macd', color='darkred', line_width=2, source=source)
p2.line(x='time', y='macd9', color='navy', line_width=2, source=source)
p2.segment(x0='time', y0=0, x1='time', y1='macdh', line_width=6, color='steelblue',
alpha=0.5, source=source)
# Combine plots together
plot = gridplot([[p], [p2]], toolbar_location="left", plot_width=1000)
# Compose html from plots and template
script, div = components(plot, theme=theme)
html = template.render(resources=CDN.render(), script=script, div=div)
return html
class IndexHandler(RequestHandler):