
I would like to use the Spinner Widget (instead of TextInput) to enter numerical values. Anybody, who can share an example of how to do this? Or anybody, who knows where I can find examples of how to do this?
from bokeh.plotting import figure, show
from bokeh.models import CustomJS, TextInput, Paragraph, ColumnDataSource
from bokeh.layouts import widgetbox, column
"""Plot depending on User Input."""
x = [xi * 0.001 for xi in range(0, 1000)]
a = 1
y = [a*xi for xi in x]
source = ColumnDataSource(
data=dict(x=x, y=y)
)
plot = figure(
plot_width=400, plot_height=400,
x_axis_label="x",y_axis_label="y",
toolbar_location=None,
active_drag=None,
background_fill_color=None,
border_fill_color=None
)
plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)
callback = CustomJS(args=dict(source=source), code="""
var data = source.data;
var input = cb_obj.value;
a = input
var x = data['x'];
var y = data['y'];
for (var i = 0; i < x.length; i++) {
y[i] = a*x[i];
}
source.change.emit();
""")
text_input = TextInput(value="", title="Plotting y(x) = 1 x. To enter y(x) = a x, enter a:", callback=callback)
layout = column(text_input, plot)
show(layout)



