Right way to plot live data with django and bokeh

Hello,
i have a bokeh plot embedded in a django app. I create the plot in the django view and push the plot to the bokeh server to show the plot in my webpage.

#view.py
def view_plot(request):
    f=figure()
    f.plot(#some data#)
    session = push_session(curdoc())
    context = {'script': autoload_server(f, session_id=session.id)}
    return render_to_response('plot.html', context=context)

It all works quite good. Now I want to do a live plot, every time when a new DB-Entry is created the plot should be updated. I'm not sure what is the best way.

Is it a good practice to use a timer on the webpage to ask for now data?

Or is there a way to push the update form the server so that every currently connected client gets the plot update?

I would be very thankful for every hint.

Thanks a lot.

Hi,

I would recommend checking out the happiness demo which does exactly that: https://github.com/bokeh/bokeh-demos/tree/master/happiness

Also check out the notebook where i document my learnings in making the app and how to update the data.

Basically you're going to need to keep track of your open sessions and put the new data in them, maybe using a django signal.

Best,

Sarah Bird
[email protected]

···

On Apr 26, 2016, at 5:35 AM, [email protected] wrote:

Hello,
i have a bokeh plot embedded in a django app. I create the plot in the django view and push the plot to the bokeh server to show the plot in my webpage.

#view.py
def view_plot(request):
   f=figure()
   f.plot(#some data#)
   session = push_session(curdoc())
   context = {'script': autoload_server(f, session_id=session.id)}
   return render_to_response('plot.html', context=context)

It all works quite good. Now I want to do a live plot, every time when a new DB-Entry is created the plot should be updated. I'm not sure what is the best way.

Is it a good practice to use a timer on the webpage to ask for now data?

Or is there a way to push the update form the server so that every currently connected client gets the plot update?

I would be very thankful for every hint.

Thanks a lot.

--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9dbfe7b2-a945-4767-bab4-f9da09c73e29%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hello Sarah,

thank you for fast and perfect answer. It looks like it is exactly what I need. Thanks for that and for the great work of the bokeh team.

Best,

S. Farm

···

Sarah Bird [email protected] schrieb am Mi., 27. Apr. 2016 um 05:33 Uhr:

Hi,

I would recommend checking out the happiness demo which does exactly that: https://github.com/bokeh/bokeh-demos/tree/master/happiness

Also check out the notebook where i document my learnings in making the app and how to update the data.

Basically you’re going to need to keep track of your open sessions and put the new data in them, maybe using a django signal.

Best,

Sarah Bird

[email protected]

On Apr 26, 2016, at 5:35 AM, [email protected] wrote:

Hello,

i have a bokeh plot embedded in a django app. I create the plot in the django view and push the plot to the bokeh server to show the plot in my webpage.

#view.py

def view_plot(request):

f=figure()

f.plot(#some data#)

session = push_session(curdoc())

context = {‘script’: autoload_server(f, session_id=session.id)}

return render_to_response(‘plot.html’, context=context)

It all works quite good. Now I want to do a live plot, every time when a new DB-Entry is created the plot should be updated. I’m not sure what is the best way.

Is it a good practice to use a timer on the webpage to ask for now data?

Or is there a way to push the update form the server so that every currently connected client gets the plot update?

I would be very thankful for every hint.

Thanks a lot.

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 [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9dbfe7b2-a945-4767-bab4-f9da09c73e29%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

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 [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0FAF5C8F-4A23-4F58-B560-B6EB5165CB75%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

Links to that demo have 404’d. Can someone point me in the right direction?

···

On Wednesday, April 27, 2016 at 12:33:47 AM UTC-3, Sarah Bird wrote:

Hi,

I would recommend checking out the happiness demo which does exactly that: https://github.com/bokeh/bokeh-demos/tree/master/happiness

Also check out the notebook where i document my learnings in making the app and how to update the data.

Basically you’re going to need to keep track of your open sessions and put the new data in them, maybe using a django signal.

Best,

Sarah Bird

[email protected]

On Apr 26, 2016, at 5:35 AM, [email protected] wrote:

Hello,

i have a bokeh plot embedded in a django app. I create the plot in the django view and push the plot to the bokeh server to show the plot in my webpage.

#view.py

def view_plot(request):

f=figure()

f.plot(#some data#)

session = push_session(curdoc())

context = {‘script’: autoload_server(f, session_id=session.id)}

return render_to_response(‘plot.html’, context=context)

It all works quite good. Now I want to do a live plot, every time when a new DB-Entry is created the plot should be updated. I’m not sure what is the best way.

Is it a good practice to use a timer on the webpage to ask for now data?

Or is there a way to push the update form the server so that every currently connected client gets the plot update?

I would be very thankful for every hint.

Thanks a lot.


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 [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9dbfe7b2-a945-4767-bab4-f9da09c73e29%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

That early demo lapsed into non-functionality and was overly complicated by trying to do some specialized and advanced things with custom session creation. Most of these cases can probably now be more easily handled with things like HTTP request args. So I'd suggest starting with the general information about embedding, since embedding in Django is not going to be materially different from embedding in Flask or any other web framework:

  http://bokeh.pydata.org/en/latest/docs/user_guide/embed.html

  http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#embedding-bokeh-server-as-a-library

That said, an explicit Django example would be a welcome addition to the examples or docs, in case you'd like to submit a contrition. None of the current core devs have any experience with Django.

Thanks,

Bryan

···

On Aug 5, 2017, at 21:18, [email protected] wrote:

Hi,

Links to that demo have 404'd. Can someone point me in the right direction?

On Wednesday, April 27, 2016 at 12:33:47 AM UTC-3, Sarah Bird wrote:
Hi,

I would recommend checking out the happiness demo which does exactly that: https://github.com/bokeh/bokeh-demos/tree/master/happiness

Also check out the notebook where i document my learnings in making the app and how to update the data.

Basically you're going to need to keep track of your open sessions and put the new data in them, maybe using a django signal.

Best,

Sarah Bird
[email protected]

> On Apr 26, 2016, at 5:35 AM, [email protected] wrote:
>
> Hello,
> i have a bokeh plot embedded in a django app. I create the plot in the django view and push the plot to the bokeh server to show the plot in my webpage.
>
> #view.py
> def view_plot(request):
> f=figure()
> f.plot(#some data#)
> session = push_session(curdoc())
> context = {'script': autoload_server(f, session_id=session.id)}
> return render_to_response('plot.html', context=context)
>
>
> It all works quite good. Now I want to do a live plot, every time when a new DB-Entry is created the plot should be updated. I'm not sure what is the best way.
>
> Is it a good practice to use a timer on the webpage to ask for now data?
>
> Or is there a way to push the update form the server so that every currently connected client gets the plot update?
>
> I would be very thankful for every hint.
>
> Thanks a lot.
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9dbfe7b2-a945-4767-bab4-f9da09c73e29%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/a4f1eaf6-ad5a-440f-8356-bce61bffcae2%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.