Skip to content

Tooltip is not being updating using CustomJS callback  #1

Description

@manish-singla

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions