I want to do something like this. I create a few widgets, for example a dropdown list , a multiselect box and a text input box. Then I add a button. When users select the variables in the widgets and click the button. The values they have selected will be downloaded as txt files. I want this html to be usable without bokeh server so I would appreciate if someone can get it done through customJS.
Really appreciate it.
from random import random
from bokeh.plotting import figure, output_file, show, ColumnDataSource
from bokeh.models import CustomJS, Button
from bokeh.layouts import row, column
savebutton = Button(label="Save", button_type="success")
savebutton.callback = CustomJS(args=dict(multi_select1.value,multi_select2.value), code="""
var value1 = multi_select1.value;
var value2 = multi_select1.value;
var out = "";
for (i = 0; i < value1.length; i++) {
out += value1[i];
}
for (i = 0; i < value2.length; i++) {
out += value2[i];
}
var file = new Blob([out], {type: 'text/plain'});
var elem = window.document.createElement('a');
elem.href = window.URL.createObjectURL(file);
elem.download = 'selected-data.txt';
document.body.appendChild(elem);
elem.click();
document.body.removeChild(elem);
""")
assets=['asset1','asset2','asset3','asset4']
multi_select1 = MultiSelect(title="Select:", value=['asset1'],options=assets, height=200, width=100)
multi_select2 = MultiSelect(title="Select:", value=['asset1'],options=assets, height=200, width=100)
plot = column(multi_select1,multi_select2,savebutton)
show(plot)