I would like some help translating my callback function in bokeh from python to javascript. My code is showed next (I've deleted most of it since it was not important to the translation.)
#returns a CDS of a dataframe based on one parameter
def create_df(option):
return ColumnDataSource(incident_df)
all_df = create_df('all')
critical_df = create_df('1')
high_df = create_df('2')
avg_low_df = create_df('3/4')
data_points = create_df('all')
color_mapper=LinearColorMapper(palette=RdBu7,low=data_points.data['freq'].min(),high=data_points.data['freq'].max())
radio_button_group = RadioButtonGroup(
labels=["All Priorities", "1 - Critical", "2 - High", "3/4 - Average/Low"], active=0)
#Define the callback function
def callback(attr, old, new):
if radio_button_group.active == 0:
new_cds = all_df
if radio_button_group.active == 1:
new_cds = critical_df
if radio_button_group.active == 2:
new_cds = high_df
if radio_button_group.active == 3:
new_cds = avg_low_df
data_points.data = new_cds.data
color_mapper.low=min(data_points.data['freq'])
color_mapper.high=max(data_points.data['freq'])
radio_button_group.on_change('active', callback)