MCPcopy Create free account
hub / github.com/pywebio/PyWebIO / bkapp

Function bkapp

test/11.charts.py:18–57  ·  view source on GitHub ↗
(doc)

Source from the content-addressed store, hash-verified

16
17
18def bkapp(doc):
19 import yaml
20
21 from bokeh.layouts import column
22 from bokeh.models import ColumnDataSource, Slider
23 from bokeh.plotting import figure
24 from bokeh.sampledata.sea_surface_temperature import sea_surface_temperature
25 from bokeh.themes import Theme
26 df = sea_surface_temperature.copy()
27 source = ColumnDataSource(data=df)
28
29 plot = figure(x_axis_type='datetime', y_range=(0, 25),
30 y_axis_label='Temperature (Celsius)',
31 title="Sea Surface Temperature at 43.18, -70.43")
32 plot.line('time', 'temperature', source=source)
33
34 def callback(attr, old, new):
35 if new == 0:
36 data = df
37 else:
38 data = df.rolling('{0}D'.format(new)).mean()
39 source.data = ColumnDataSource.from_df(data)
40
41 slider = Slider(start=0, end=30, value=0, step=1, title="Smoothing by N Days")
42 slider.on_change('value', callback)
43
44 doc.add_root(column(slider, plot))
45
46 doc.theme = Theme(json=yaml.load("""
47 attrs:
48 Figure:
49 background_fill_color: "#DDDDDD"
50 outline_line_color: white
51 toolbar_location: above
52 height: 500
53 width: 800
54 Grid:
55 grid_line_dash: [6, 4]
56 grid_line_color: white
57 """, Loader=yaml.FullLoader))
58
59
60def basci_doc():

Callers

nothing calls this directly

Calls 1

SliderClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…