···
On Tue, Nov 3, 2015 at 12:00 PM, hkbokeh hamidreza.khakpour@gmail.com wrote:
Fabio,
What is the Plot_2 in my case? Is it the slider? I tried this and it did not work (I can only see my plot not the slider)
from bokeh.models.widgets import Slider
p = figure(tools = TOOLS, x_axis_label = ‘time (secs)’, y_axis_label = ’ (bbls/hr)', plot_width = 1200, plot_height = 800)
p.line(dftemp[‘timestamp’].sub(dftemp.iloc[0,0], axis = 0), ens[j], line_width = 4, line_color = “navy”)
slider = Slider(start=0, end=10, value=1, step=.1, title=“Stuff”)
***script, div = components(p, slider) ***
Components will take wither a tuple or a dict with our objects… so in your case:
components((p, slider))
#=> (script, (p_div, slider_div))
components({"p": p, "slider": slider})
#=> (script, {"p": p_div, "slider": slider_div})
where p_div and slider_div are the divs containing your components to use on your page template
render my HTML file:
return render_template(‘bo.html’, script = script, div= div)
My HTML file using Jinja2 Template file:
{% extends “template.html” %}
{% block content %}
Event:
{{ script | safe }}
{{ div | safe }}
{% endblock %}
Thanks a lot for your help.
Notice that your script and resources should go into your page header…
also, in case your are calling:
components({"p": p, "slider": slider})
#=> (script, {"p": p_div, "slider": slider_div})
you should end up with something like this…
{% extends “template.html” %}
{% block content %}
Event:
{{ div.p | safe }}
{{ div.slider | safe }}
{% endblock %}
You can also look at the embed multiple example for a working example that you can run locally and adapt to your usecase.
On Tuesday, November 3, 2015 at 11:01:51 AM UTC-5, hkbokeh wrote:
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 by:
render_template(.html, script = script, div =div)
I want to add a interactive slider bar on top of my Bokeh 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 the new “div” and “script” elements to the HTML file to update my plots?
I really appreciate if you could explain necessary steps to me to achieve this solution.
–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/c36ed2e7-5906-4b74-9f78-17877e65d201%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
–
Fabio Pliger
Senior Software Engineer, Bokeh