Skip to content Skip to sidebar Skip to footer

How To Update Source Of Bokeh Downloadbutton From A Function That Is Invoked By A Widget

How to update source of a downloadbutton of Bokeh? In my case, I am calling update() when other widgets are being invoked. The update() function is also the place i will update 'df

Solution 1:

Finally found a way. Inside the function where the dataframe was getting updated, we need to use source.data = and not source =

Here is how it should look:

df=pd.DataFrame()
source = ColumnDataSource(df) # initialize to whatever u want

def update()
   # some process...
   df_updated = <whatever>
   cds = ColumnDataSource(df_updated)
   source.data = dict(cds.data)  # this is what was the difference in the end

downloadbutton.js_on_click(CustomJS(args=dict(source=source),
                            code=open(join(dirname(__file__), "download.js")).read()))

myselect.on_click(update) # call update() to update the df

Post a Comment for "How To Update Source Of Bokeh Downloadbutton From A Function That Is Invoked By A Widget"