1 回答

TA貢獻(xiàn)1982條經(jīng)驗(yàn) 獲得超2個(gè)贊
可以在小部件之間共享單個(gè)CustomJS回調(diào),但您不能使用cb_obj。您必須顯式傳遞小部件。
callback = CustomJS(args=dict(source=source,
filteredSource=filteredSource,
userm=userm, locations=locations),
code="""
const data = source.data;
const userm_value = userm.value;
const locations_value = locations.value;
const df2 = filteredSource.data;
df2['User'] = [];
df2['Location'] = [];
for (let i = 0; i < data['User'].length; i++) {
if (data['User'][i] === userm_value && data['Location'][i] === locations_value) {
df2['User'].push(data['User'][i])
df2['Location'].push(data['Location'][i])
}
}
filteredSource.change.emit()
""")
userm.js_on_change('value', callback)
locations.js_on_change('value', callback)
添加回答
舉報(bào)