-
-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bokeh server support #959
Merged
Merged
Bokeh server support #959
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
ab26f51
Added BokehRenderer server mode
philippjfr c1e2550
Added initial bokeh server stream callback handling
philippjfr afec80f
Small fixes for bokeh server implementation
philippjfr 312975e
Added initial BokehServerWidgets implementation
philippjfr 6f420b3
Fixes for BokehServerWidgets
philippjfr 3b5d10c
Ensure all subplots have the same plotting classes
philippjfr c7cedc2
Defined bokeh widget parameters
philippjfr 3b43aab
Added bokeh app examples
philippjfr 7697a2a
Small fix for bokeh widget import
philippjfr 27ee566
Improved handling of boomeranging events in bokeh backend
philippjfr 78a2c2a
Improved bokeh server event queue
philippjfr c32e2ab
Improved range updates for bokeh server
philippjfr 3f0dca8
Fixed small bugs in bokeh Callbacks
philippjfr 9bf0982
Fixed bokeh event callbacks after change to cb_obj
philippjfr b099b7e
Implemented UIEvent handling for bokeh server
philippjfr dbef691
Moved bokeh server example apps
philippjfr 2e9ca71
Completely refactored bokeh Callbacks
philippjfr d7f5e45
Made callback utilities into classmethods
philippjfr 6ab8861
Minor cleanup on bokeh Callbacks
philippjfr 82074b8
Added tests for bokeh Callbacks
philippjfr a8a10a5
Small fix for bokeh ServerCallback on_change events
philippjfr 3342b0a
Allow supplying Document to BokehRenderer
philippjfr c65dcbb
Simplified bokeh Callback initialization
philippjfr a2fcb0c
Moved bokeh server widget handling onto BokehRenderer
philippjfr b0e1f52
Factored out class method to create bokeh widgets
philippjfr d9fe1b7
Small fixes and improvements for bokeh widgets
philippjfr f0c31c6
Added tests for BokehServerWidgets
philippjfr 171e9ca
Fixed unreferenced variable bugs
philippjfr 4e8073a
Various python3 fixes
philippjfr 957b96b
Improved docstrings for bokeh server features
philippjfr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
holoviews/plotting/bokeh/examples/apps/apps/crossfilter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import numpy as np | ||
import pandas as pd | ||
import holoviews as hv | ||
import holoviews.plotting.bokeh | ||
|
||
from bokeh.layouts import row, widgetbox | ||
from bokeh.models import Select | ||
from bokeh.plotting import curdoc, figure | ||
from bokeh.sampledata.autompg import autompg | ||
|
||
df = autompg.copy() | ||
|
||
SIZES = list(range(6, 22, 3)) | ||
ORIGINS = ['North America', 'Europe', 'Asia'] | ||
|
||
# data cleanup | ||
df.cyl = [str(x) for x in df.cyl] | ||
df.origin = [ORIGINS[x-1] for x in df.origin] | ||
|
||
df['year'] = [str(x) for x in df.yr] | ||
del df['yr'] | ||
|
||
df['mfr'] = [x.split()[0] for x in df.name] | ||
df.loc[df.mfr=='chevy', 'mfr'] = 'chevrolet' | ||
df.loc[df.mfr=='chevroelt', 'mfr'] = 'chevrolet' | ||
df.loc[df.mfr=='maxda', 'mfr'] = 'mazda' | ||
df.loc[df.mfr=='mercedes-benz', 'mfr'] = 'mercedes' | ||
df.loc[df.mfr=='toyouta', 'mfr'] = 'toyota' | ||
df.loc[df.mfr=='vokswagen', 'mfr'] = 'volkswagen' | ||
df.loc[df.mfr=='vw', 'mfr'] = 'volkswagen' | ||
del df['name'] | ||
|
||
columns = sorted(df.columns) | ||
discrete = [x for x in columns if df[x].dtype == object] | ||
continuous = [x for x in columns if x not in discrete] | ||
quantileable = [x for x in continuous if len(df[x].unique()) > 20] | ||
|
||
hv.Store.current_backend = 'bokeh' | ||
renderer = hv.Store.renderers['bokeh'] | ||
options = hv.Store.options(backend='bokeh') | ||
options.Points = hv.Options('plot', width=800, height=600, size_index=None,) | ||
options.Points = hv.Options('style', cmap='rainbow', line_color='black') | ||
|
||
def create_figure(): | ||
label = "%s vs %s" % (x.value.title(), y.value.title()) | ||
kdims = [x.value, y.value] | ||
|
||
opts, style = {}, {} | ||
opts['color_index'] = color.value if color.value != 'None' else None | ||
if size.value != 'None': | ||
opts['size_index'] = size.value | ||
opts['scaling_factor'] = (1./df[size.value].max())*200 | ||
points = hv.Points(df, kdims=kdims, label=label)(plot=opts, style=style) | ||
plot = renderer.get_plot(points) | ||
plot.initialize_plot() | ||
return plot.state | ||
|
||
def update(attr, old, new): | ||
layout.children[1] = create_figure() | ||
|
||
|
||
x = Select(title='X-Axis', value='mpg', options=quantileable) | ||
x.on_change('value', update) | ||
|
||
y = Select(title='Y-Axis', value='hp', options=quantileable) | ||
y.on_change('value', update) | ||
|
||
size = Select(title='Size', value='None', options=['None'] + quantileable) | ||
size.on_change('value', update) | ||
|
||
color = Select(title='Color', value='None', options=['None'] + quantileable) | ||
color.on_change('value', update) | ||
|
||
controls = widgetbox([x, y, color, size], width=200) | ||
layout = row(controls, create_figure()) | ||
|
||
curdoc().add_root(layout) | ||
curdoc().title = "Crossfilter" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- coding: utf-8 -*- | ||
import numpy as np | ||
from bokeh.io import curdoc | ||
from bokeh.layouts import layout | ||
from bokeh.models import ( | ||
ColumnDataSource, HoverTool, SingleIntervalTicker, Slider, Button, Label, | ||
CategoricalColorMapper, | ||
) | ||
import holoviews as hv | ||
import holoviews.plotting.bokeh | ||
|
||
renderer = hv.Store.renderers['bokeh'] | ||
|
||
start = 0 | ||
end = 10 | ||
|
||
hmap = hv.HoloMap({i: hv.Image(np.random.rand(10,10)) for i in range(start, end+1)}) | ||
plot = renderer.get_plot(hmap) | ||
plot.update(0) | ||
|
||
def animate_update(): | ||
year = slider.value + 1 | ||
if year > end: | ||
year = start | ||
slider.value = year | ||
|
||
def slider_update(attrname, old, new): | ||
plot.update(slider.value) | ||
|
||
slider = Slider(start=start, end=end, value=0, step=1, title="Year") | ||
slider.on_change('value', slider_update) | ||
|
||
def animate(): | ||
if button.label == '► Play': | ||
button.label = '❚❚ Pause' | ||
curdoc().add_periodic_callback(animate_update, 200) | ||
else: | ||
button.label = '► Play' | ||
curdoc().remove_periodic_callback(animate_update) | ||
|
||
button = Button(label='► Play', width=60) | ||
button.on_click(animate) | ||
|
||
layout = layout([ | ||
[plot.state], | ||
[slider, button], | ||
], sizing_mode='fixed') | ||
|
||
curdoc().add_root(layout) |
17 changes: 17 additions & 0 deletions
17
holoviews/plotting/bokeh/examples/apps/apps/selection_stream.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import numpy as np | ||
import holoviews as hv | ||
import holoviews.plotting.bokeh | ||
from holoviews.streams import Selection1D | ||
|
||
hv.Store.current_backend = 'bokeh' | ||
renderer = hv.Store.renderers['bokeh'].instance(mode='server') | ||
hv.Store.options(backend='bokeh').Points = hv.Options('plot', tools=['box_select']) | ||
|
||
data = np.random.multivariate_normal((0, 0), [[1, 0.1], [0.1, 1]], (1000,)) | ||
points = hv.Points(data) | ||
sel = Selection1D(source=points) | ||
mean_sel = hv.DynamicMap(lambda index: hv.HLine(points['y'][index].mean() | ||
if index else -10), | ||
kdims=[], streams=[sel]) | ||
doc,_ = renderer((points * mean_sel)) | ||
doc.title = 'HoloViews Selection Stream' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it only rendering DynamicMaps? Might want a bit more to say what server mode is about ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, not sure why I wrote that. It handles anything.