Working with a figure and a RadioButtonGroup, I have callback functions for both which should result in a change in the figure/RBG when a change in the RBG/figure occurs, respectively.
However, when the figure callback is triggered and changes the value of the RBG, the BRG callback is triggered as well (i.e the RBG callback is triggered not when the button is clicked but when it’s value changes).
How do I trigger the RBG callback only if the buttons are clicked on?
#Create RBG
cZone = RadioButtonGroup (
labels=cZoneList,
active=-1,
)
rbgCallback = CustomJS(args=dict(source=geosource),code="""
console.log(‘rbgCallback event’)
console.log(cb_obj)
“”")
#Create figure object.
p = figure(title = ‘USA Climate Zone Map’, plot_height = 450 , plot_width = 800, toolbar_location = “below”, tools=select_tools)
p.add_tools(hover)
p.add_tools(tap)
figureCallback = CustomJS(args=dict(source=geosource, rbg=cZone),code="""
console.log(‘Tap event’)
var n = source.selected.indices.length
console.log(n)
if (n>0) {
rbg.active = source.selected.indices[0]
} else {
rbg.active = -1
}
“”")
#on event
p.js_on_event(‘tap’, figureCallback)
cZone.js_on_click(rbgCallback)
#show
layout = column(p, cZone)
show(layout)
``


