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

Tooltip is not being updating using CustomJS callback #1

Open
manish-singla opened this issue Mar 24, 2020 · 1 comment
Open

Tooltip is not being updating using CustomJS callback #1

manish-singla opened this issue Mar 24, 2020 · 1 comment

Comments

@manish-singla
Copy link

While running world_obesity.ipynb on local python, not using docker, I got the following error:

Only JavaScript callbacks may be used with standalone output. For more
information on JavaScript callbacks with Bokeh, see: https://docs.bokeh.org/en/latest/docs/user_guide/interaction/callbacks.html

How to update the Custom JS callback js_on_change for update_plot function:

# Define the callback function: def update_plot(attr, old, new): yr = slider.value new_data = json_data(yr) geosource.geojson = new_data p.title.text = 'Share of adults who are obese, %d' %yr slider = Slider(title = 'Year',start = 1975, end = 2016, step = 1, value = 2016) slider.on_change('value', update_plot)

and the function it is calling:
def json_data(selectedYear): yr = selectedYear df_yr = df[df['year'] == yr] merged = gdf.merge(df_yr, left_on = 'country_code', right_on = 'code', how = 'left') merged.fillna('No data', inplace = True) merged_json = json.loads(merged.to_json()) json_data = json.dumps(merged_json) return json_data

@manish-singla manish-singla changed the title Tooltip is not being ipUsing CustomJS callback Tooltip is not being updating using CustomJS callback Mar 24, 2020
@gowrijp
Copy link

gowrijp commented May 8, 2020

Try adding this in your ipynb notebook:-

from bokeh.resources import INLINE
import bokeh.io
bokeh.io.output_notebook(INLINE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants