Glyph patches fill_color not updating on RangeSlider callback

Hi

Taking inspiration from the Gapminder project implemented using Bokeh, I was trying to update the colors of the states on the US map based on the amount of fuel consumed by electric vehicles within the year range determined by the range slider and subsequently create an animation.

However, I’m running into the following issue: While the slider callback updates the color values for each patch in the ColumnDataSource, it does not plot the updated data on the map.

I have attached a screenshot of the map plotted so far, and a well-commented zip file containing the data and a Jupyter Notebook.

Any help would be appreciated. Thank you!

Bokeh issue.zip (152 KB)

Hi,

Two immediate issues. This comment:

p = make_plot(src) #ISSUE: THIS IS NOT BEING CALLED ON ANY UPDATE TO THE SLIDER!!!!

exposes a misunderstanding. The only code that is called when the slider is updated is the callback code that you register for changes to the slider value, i.e. your “update” function. This code above is not in that callback. You should therefore not expect it to be called when the slider updates. It will only be called once, when the app is created initially by modify_doc.

Next, you are replacing the entire CDS in your update. Don’t do this. The Bokeh CDS is a central but heavyweight piece of machinery. Instead of replacing entire CDS objects, you should only set the .data property of an existing CDS. This is how all of the documentation and examples demonstrate doing things, e,g.

[https://github.com/bokeh/bokeh/blob/master/examples/app/sliders.py#L66](https://github.com/bokeh/bokeh/blob/master/examples/app/sliders.py#L66)

Thanks,

Bryan

···

On Jul 17, 2018, at 12:12, [email protected] wrote:

Hi

Taking inspiration from the Gapminder project implemented using Bokeh, I was trying to update the colors of the states on the US map based on the amount of fuel consumed by electric vehicles within the year range determined by the range slider and subsequently create an animation.

However, I’m running into the following issue: While the slider callback updates the color values for each patch in the ColumnDataSource, it does not plot the updated data on the map.

I have attached a screenshot of the map plotted so far, and a well-commented zip file containing the data and a Jupyter Notebook.

Any help would be appreciated. Thank you!

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9a55a133-d891-46ff-ae4f-6c5819b5e8e5%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.