Thank you for your reply. Well, the callback function for changing the display is
filter = CustomJSFilter(code="""
let selected = checkboxes.active.map(i=>checkboxes.labels[i]);
let indices = [];
let column = source.data['FOR'];
for(let i=0; i<column.length; i++){
if(selected.includes(column[i])){
indices.push(i);
}
}
return indices;
""", args=dict(checkboxes=checkboxes, source=source))
and it is called with
checkboxes.js_on_change("active", CustomJS(code="source.change.emit();", args=dict(source=source)))
I was hoping to define another filter function and have that called by the button callback:
all = Button(label='All')
def every():
checkboxes.js_on_change("active", CustomJS(code="source.change.emit();", args=dict(source=source),filter_all))
all.js_on_click(every())
where filter_all is another filter function which simply returns all indices:
filter_all = CustomJSFilter(code="""
let indices = [];
for(let i=0; i<column.length; i++){
indices.push(i);
}
return indices;
""", args=dict(checkboxes=checkboxes, source=source))
This doesn’t work. I have lots of confusion about the relative behaviour of JavaScript and Python, as well as some more particular questions:
- How can I set the particular callback function to be used in a callback? The function
filter is not given in the checkboxes callback: I imagine if there is only one function it is automatically taken to be the function needed.
- What I’ve attempted to do is clumsy: use the button to call another function which sets the state of all the checkboxes. As well as not working (how do the checkboxes get information from this set of indices?), it’s a mixture of Python and JavaScript. And I want callbacks to be JavaScript only.
- Probably a better way would be for the button to simply plot all the scatter plots generated from the pandas DataFrame that holds the data. But the problem with that is that I’m not fully sure how to include plotting commands within a JavaScript function.
Anyway, any pointers - or even better, examples - would be terrific! Thanks again.
Summary
This text will be hidden