Streaming Data in Bokeh

Hi,

I have a problem, and I did not find a soltion with Bokeh v 0.12.2, so I am asking this here:

I have a simple line graph:

 p = figure(x_axis_type="datetime", plot_width=1000) #, responsive = True)
 p.line(df.date, df.close, name = 'Line')
 renderer = p.select(dict(name="Line"))
 self.ds = renderer[0].data_source          
 show(p)

``

I am displaying that via bokeh server in a browser, and whenever a new data point is added to the line, I would like to add it to the already open display in the browser:

 df = self.graphDataFrame.tail(250) ## only the last
 self.ds.data['x'] = df.date
 self.ds.data['y'] = df.close
 self.ds._dirty = True

 session = pull_session(curdoc())
 session.store_objects(self.ds)

``

But it is not working, the screen does not change. Can you help me - what am I doing wrong?

Thanks,
Ernst

Seems like you’re going about that in a very complicated way.

Why not use source.stream or source.patch?

There's an example of source.stream here:
···

https://github.com/bokeh/bokeh/blob/master/examples/app/ohlc/main.py

On 10/7/16 7:27 AM, Ernst wrote:

Hi,

    I have a problem, and I did not find a soltion with Bokeh v

0.12.2, so I am asking this here:

    I have a simple line graph:


 p = figure(x_axis_type="datetime",
            plot_width=1000)                 #,

responsive = True)

                 p.line(df.date, df.close, name = 'Line')

                 renderer = p.select(dict(name="Line"))

                 self.ds =
            renderer[0].                data_source
     

                 show(p)

``

    I am displaying that via bokeh server in a browser, and whenever

a new data point is added to the line, I would like to add it to
the already open display in the browser:

 df = self.graphDataFrame.tail(250)                 ## only

the last

                 self.ds.data['x'] = df.date

                 self.ds.data['y'] = df.close

                 self.ds._dirty = True



                 session = pull_session(curdoc())

                 session.store_objects(self.ds)

``

    But it is not working, the screen does not change. Can you help

me - what am I doing wrong?

    Thanks,

    Ernst

  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/87ab80f2-8630-4d8b-a8b6-f1ec52b0185e%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/87ab80f2-8630-4d8b-a8b6-f1ec52b0185e%40continuum.io?utm_medium=email&utm_source=footer).

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


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

Hi Sarah,
thank you very much for your mail. It is working and looks great, but it runs as an app to be started with bokeh --serve.

However, I have quite a big python code (involving TensorFlow and such) and I would rather have the bokeh code in a few functions I can call whenever something is happening in TensorFlow. So I do not want to run the whole stuff as Bokeh server app, but control the Bokeh parts from inside my python code.

Is this possible with the example you sent me?

Thanks and kind regards
Ernst

···

On Sunday, October 9, 2016 at 9:16:28 AM UTC+2, Sarah Bird wrote:

Seems like you’re going about that in a very complicated way.

Why not use source.stream or source.patch?

There's an example of source.stream here:

https://github.com/bokeh/bokeh/blob/master/examples/app/ohlc/main.py

On 10/7/16 7:27 AM, Ernst wrote:

Hi,

    I have a problem, and I did not find a soltion with Bokeh v

0.12.2, so I am asking this here:

    I have a simple line graph:


 p = figure(x_axis_type="datetime",
            plot_width=1000)                 #,

responsive = True)

                 p.line(df.date, df.close, name = 'Line')

                 renderer = p.select(dict(name="Line"))

                 self.ds =
            renderer[0].                data_source
     

                 show(p)

``

    I am displaying that via bokeh server in a browser, and whenever

a new data point is added to the line, I would like to add it to
the already open display in the browser:

 df = self.graphDataFrame.tail(250)                 ## only

the last

                 self.ds.data['x'] = df.date

                 self.ds.data['y'] = df.close

                 self.ds._dirty = True



                 session = pull_session(curdoc())

                 session.store_objects(self.ds)

``

    But it is not working, the screen does not change. Can you help

me - what am I doing wrong?

    Thanks,

    Ernst

  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/87ab80f2-8630-4d8b-a8b6-f1ec52b0185e%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/87ab80f2-8630-4d8b-a8b6-f1ec52b0185e%40continuum.io?utm_medium=email&utm_source=footer).

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


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" width="150px" height="30px">
    ](http://continuum.io)

The only simple way to update the front end from python code is:

  1. use bokeh server

  2. use p ush_notebook
    in the notebook environment

                     I can't immediately think
    

of any way of achiev ing
what you want to.

···

On 10/9/16 11:24 PM, Ernst wrote:

Hi Sarah,

    thank you very much for your mail. It is working and looks

great, but it runs as an app to be started with bokeh --serve.

    However, I have quite a big python code (involving TensorFlow

and such) and I would rather have the bokeh code in a few
functions I can call whenever something is happening in
TensorFlow. So I do not want to run the whole stuff as Bokeh
server app, but control the Bokeh parts from inside my python
code.

    Is this possible with the example you sent me?



    Thanks and kind regards

    Ernst





    On Sunday, October 9, 2016 at 9:16:28 AM UTC+2, Sarah Bird

wrote:

          Seems like you're going about that in a very complicated

way.

Why not use source.stream or source.patch?

        There's an example of source.stream here: [https://github.com/bokeh/bokeh/blob/master/examples/app/ohlc/main.py](https://github.com/bokeh/bokeh/blob/master/examples/app/ohlc/main.py)

On 10/7/16 7:27 AM, Ernst wrote:

Hi,

            I have a problem, and I did not find a soltion with

Bokeh v 0.12.2, so I am asking this here:

            I have a simple line graph:


 p = figure(x_axis_type="datetime", plot_width=1000) #, responsive = True)

                         p.line(df.date, df.close, name = 'Line')

                         renderer = p.select(dict(name="Line"))

                         self.ds = renderer[0].data_source          

                         show(p)

``

            I am displaying that via bokeh server in a browser, and

whenever a new data point is added to the line, I would
like to add it to the already open display in the
browser:

 df = self.graphDataFrame.tail(250) ## only the last

                         self.ds.data['x'] = df.date

                         self.ds.data['y'] = df.close

                         self.ds._dirty = True



                         session = pull_session(curdoc())

                         session.store_objects(self.ds)

``

            But it is not working, the screen does not change. Can

you help me - what am I doing wrong?

            Thanks,

            Ernst

          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/87ab80f2-8630-4d8b-a8b6-f1ec52b0185e%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/87ab80f2-8630-4d8b-a8b6-f1ec52b0185e%40continuum.io?utm_medium=email&utm_source=footer).

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


Sarah Bird
Developer, Bokeh

            [ ![Continuum
                Analytics](https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000) ](http://continuum.io)

  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/6047c9d1-673c-4fd2-aef6-1873241f6285%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/6047c9d1-673c-4fd2-aef6-1873241f6285%40continuum.io?utm_medium=email&utm_source=footer).

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


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)