I have a Flask App in which my plots are created using Bokeh in the controller python code with below commands:
p = figure(tools = TOOLS, x_axis_label ...)
p.line(....)
script, div = components(p)
and I pass "script" & "div" elements to my HTML page using:
render_template(.html, script = script, div =div)
I want to add a interactive slider bar on top of my plot. Based on the Bokeh website with the following command, I should be able to do it.
slider = Slider(start=0, end=10, value=1, step=.1, title="Stuff")
So my first question is, how can I put slider information to the components function to generate correct "script" and "div" elements that I could pass it to my HTML file?
My second question is: Having a value on the slider, how can I post it back to my controller to update my plots and send new "div" and "script" elements to the HTML file to update my plots?
I really appreciate if you could explain necessary steps to achieve this solution.
Find answer for the first question below:
p.line(.....)
slider1 = Slider(start=0, end = 100, value = y[j] / bth, step = 1, title = "Mag")
slider2 = Slider(start=0, end = 100, value = y1[j] / bth, step = 1, title = "test")
script, div = components({"p": p, "slider1":vform(slider1), "slider2":vform(slider2)})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With