Skip to content
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

InteractiveImage callbacks to Flask app #279

Closed
Thru-Echoes opened this Issue Feb 7, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@Thru-Echoes
Copy link

commented Feb 7, 2017

I have created responsive Flask web apps using Bokeh plots, such as (https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/responsive.py).

I also have a IPython / Jupyter notebook running InteractiveImage with this code:

def base_plot(tools='pan,wheel_zoom,reset',webgl=False):
    p = bp.figure(tools=tools,
                  plot_width=int(900*1.0), plot_height=int(500*1.0),
                  x_range=x_range, y_range=y_range, outline_line_color=None,
                  min_border=0, min_border_left=0, min_border_right=0,
                  min_border_top=0, min_border_bottom=0, webgl=webgl)

    
    p.axis.visible = False
    p.xgrid.grid_line_color = None
    p.ygrid.grid_line_color = None
    
    return p

def image_callback(x_range, y_range, w, h):
    cvs = ds.Canvas(plot_width=w, plot_height=h, x_range=x_range, y_range=y_range)
    agg = cvs.points(df, 'meterswest', 'metersnorth', ds.count_cat('race'))
    img = tf.shade(agg, color_key=color_key, how='log')
    return tf.dynspread(img,threshold=0.75, max_px=8)

p = base_plot()

#url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}.png"
url="http://tile.stamen.com/toner-background/{Z}/{X}/{Y}.png"
tile_renderer = p.add_tile(WMTSTileSource(url=url))
tile_renderer.alpha=1.0 if background == "black" else 0.15

InteractiveImage(p, image_callback)

However, how can I use InteractiveImage with the plot and the callback in the same way in a Flask web app? It seems like InteractiveImage cannot process the callbacks to and from the server (Flask) script?

@jbednar

This comment has been minimized.

Copy link
Collaborator

commented Feb 7, 2017

Right. InteractiveImage only supports the Jupyter notebook, at least for now (see #147). We've worked out partial support for using Bokeh server via the HoloViews project, but have not yet released (or merged) that. I'll close this as a duplicate, but I hear your pain! :-/

@jbednar jbednar closed this Feb 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.