how to make a server page with the plot and extra HTML stuff

Hi,

My redis-server and bokeh-server are running. I want to have a page, say, http://localhost:5006/thomas/page1.html that will have some information I pre-typed (header, introduction to some data, etc…) and a plot, that optionally would be updated/animated… How to ? :slight_smile:

Cheers,

Thom

Hi Thomas,

I believe this same basic question was recently addressed in a GH issue:

  How to add a caption to the figure? · Issue #147 · bokeh/bokeh · GitHub

Here is the most relevant comment:

The plot server view is a very minimal "backend" view into the plot. The best way to embed a plot is to add the "embed" tool to the list of tools in the plotting script. Then, run the script and click the Embed HTML button. This will pop up an HTML <script> tag that you should drop into your web page, wherever you want the plot to be embedded.

Here is an example HTML file that I hand-crafted, and notice the <script> tag that I pasted in from using the Embed Tool:

<html>
<body>

<h2>Simple Embed Example</h2>
<p>Here is my plot:</p>
<p>
<script src="http://localhost:5006//bokeh/embed.js&quot; bokeh_plottype="serverconn"
  bokeh_docid="786205c5-8f99-4971-94b5-b14fd7174796"
  bokeh_ws_conn_string="ws://localhost:5006/bokeh/sub"
  bokeh_docapikey="" bokeh_root_url="http://localhost:5006/&quot;
  bokeh_modelid="30b1aad7-2886-437e-bf0d-34d285363da5"
  bokeh_modeltype="Plot" async="true"></script>
</p>

</body>
</html>

Let me know if additional information is needed.

Thanks,

Bryan

···

On Nov 7, 2013, at 9:05 AM, Thomas Lecocq <[email protected]> wrote:

Hi,

My redis-server and bokeh-server are running. I want to have a page, say, http://localhost:5006/thomas/page1.html that will have some information I pre-typed (header, introduction to some data, etc...) and a plot, that optionally would be updated/animated... How to ? :slight_smile:

Cheers,

Thom

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion" 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/56e67392-963b-4d1e-92d7-c3ff8438c805%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/groups/opt_out\.

Hi Bryan,

That’s working smoothly ! I wish I could embed the plot without the actual “embed” button !

Something in the same vein: would it be possible to have the script generate the embed code directly, in order to save it somewhere and have a dynamic import on my php page ?

so I could, e.g.:

python plotstuff1.py > embedsnippet1.php
python plotstuff2.py > embedsnippet2.php

and my php will include embedsnipper1 & 2 at different places in the code ?

Thanks

Thom

···

Le jeudi 7 novembre 2013 16:05:52 UTC+1, Thomas Lecocq a écrit :

Hi,

My redis-server and bokeh-server are running. I want to have a page, say, http://localhost:5006/thomas/page1.html that will have some information I pre-typed (header, introduction to some data, etc…) and a plot, that optionally would be updated/animated… How to ? :slight_smile:

Cheers,

Thom

Hi Thomas,

I don’t see why that shouldn’t be possible, but let me try to get one of the other devs that worked on the embedding code to chime in soon as well.

Another thing to mention: we definitely would like to have other “bindings” for bokehjs besides just python in the future, though such work will probably have to be driven by other interested parties. If you’d ever like to work on a plotting interface that works directly from PHP, without needing python, let us know and we can provide assistance or information.

Lastly we also want to grow our example gallery so if you develop any particularly interesting examples that you are also able and willing to share, please pass them on and we will see about including them on the bokeh.pydata.org gallery.

Thanks,

Bryan

···

On Nov 8, 2013, at 1:09 AM, Thomas Lecocq <[email protected]> wrote:

Hi Bryan,

That's working smoothly ! I wish I could embed the plot without the actual "embed" button !

Something in the same vein: would it be possible to have the script generate the embed code directly, in order to save it somewhere and have a dynamic import on my php page ?

so I could, e.g.:

python plotstuff1.py > embedsnippet1.php
python plotstuff2.py > embedsnippet2.php

and my php will include embedsnipper1 & 2 at different places in the code ?

Thanks

Thom

Le jeudi 7 novembre 2013 16:05:52 UTC+1, Thomas Lecocq a écrit :
Hi,

My redis-server and bokeh-server are running. I want to have a page, say, http://localhost:5006/thomas/page1.html that will have some information I pre-typed (header, introduction to some data, etc...) and a plot, that optionally would be updated/animated... How to ? :slight_smile:

Cheers,

Thom

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion" 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/0506f5b4-2031-47ea-80d5-57cb55b51e20%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/groups/opt_out\.

Bryan,

Hi Thomas,

I don’t see why that shouldn’t be possible, but let me try to get one of the other devs that worked on the embedding code to chime in soon as well.
Sure :slight_smile:

I’ve successfully done something like this:
f = open(“C:\Program Files (x86)\EasyPHP-5.3.6.0\www\live\index.html”,“w”)
html = “”"





%s

“”"
f.write(html % renderer._build_server_snippet()[1])
f.close()

hackish, but writes the embed code in the HTML test page. BUT, the snippet is different from the one given by the button:

Any ideas ?

Another thing to mention: we definitely would like to have other “bindings” for bokehjs besides just python in the future, though such work will probably have to be driven by other interested parties. If you’d ever like to work on a plotting interface that works directly from PHP, without needing python, let us know and we can provide assistance or information.

OK, Thanks. But from the point of view we have now, we will most probably develop on Flask directly in Py, I’ll let you know :slight_smile:

Lastly we also want to grow our example gallery so if you develop any particularly interesting examples that you are also able and willing to share, please pass them on and we will see about including them on the bokeh.pydata.org gallery.

Sure, the example I’m working on will maybe integrate too many informations (seismic waveforms etc), but this will be, at least, an tutorial on my blog and made available via github + for the example gallery !

Cheers,

Thom

···

Le vendredi 8 novembre 2013 08:21:21 UTC+1, Bryan Van de ven a écrit :

Thanks,

Bryan

On Nov 8, 2013, at 1:09 AM, Thomas Lecocq [email protected] wrote:

Hi Bryan,

That’s working smoothly ! I wish I could embed the plot without the actual “embed” button !

Something in the same vein: would it be possible to have the script generate the embed code directly, in order to save it somewhere and have a dynamic import on my php page ?

so I could, e.g.:

python plotstuff1.py > embedsnippet1.php

python plotstuff2.py > embedsnippet2.php

and my php will include embedsnipper1 & 2 at different places in the code ?

Thanks

Thom

Le jeudi 7 novembre 2013 16:05:52 UTC+1, Thomas Lecocq a écrit :

Hi,

My redis-server and bokeh-server are running. I want to have a page, say, http://localhost:5006/thomas/page1.html that will have some information I pre-typed (header, introduction to some data, etc…) and a plot, that optionally would be updated/animated… How to ? :slight_smile:

Cheers,

Thom


You received this message because you are subscribed to the Google Groups “Bokeh Discussion” 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/0506f5b4-2031-47ea-80d5-57cb55b51e20%40continuum.io.

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

Thomas,

Thanks for the interest. We do have functions for embed snippets, they should be better documented.

Here is the main interface.

https://github.com/ContinuumIO/bokeh/blob/master/bokeh/objects.py#L309

It can be used like this:
l = line(x,y, color=“#0000FF”, tools=“pan,zoom,resize”)
print l.inject_snippet(server=True)

I want to move all of our output methods to using the inject_snippet calls. One option that we don’t have for inject_snippet which we should is “inline_js”. This would write out a whole script block that would do all of the injecting without requiring a separate js file.

There are a set of examples in https://github.com/ContinuumIO/bokeh/blob/master/bokeh/server/views/main.py#L274 . You can view them on your local server at http://localhost:5006/bokeh/generate_embed/direct/no_js and similar URLs. this should be better documented.

Finally, I eventually want to add a JS only embed tool. This tool should construct the data snippet entirley in JS and present the embed string to the user. Currently the embed string is derived in python.

In an upcoming release we will add S3 integration so that it is very easy to upload your embed snippets to S3 and get permanent URLs.

I hope this helps,
Paddy

···

On Thursday, November 7, 2013 10:05:52 AM UTC-5, Thomas Lecocq wrote:

Hi,

My redis-server and bokeh-server are running. I want to have a page, say, http://localhost:5006/thomas/page1.html that will have some information I pre-typed (header, introduction to some data, etc…) and a plot, that optionally would be updated/animated… How to ? :slight_smile:

Cheers,

Thom

Just an FYI -- I just installed the latest Anaconda
(Anaconda-1.8.0-Linux-x86.sh) on Ubuntu 10.04.
Ran bokeh-server command, but it needed redis, which
was not installed. Tried 'conda install redis', which
claimed it worked (redis showed up in 'conda list'), but
bokeh-server couldn't find it -- turned out that
'import redis' also failed at the python prompt, and
there was no redis in the site-packages directory.
Then tried 'pip install redis', which worked and then
the bokeh-server started up okay.

Maybe something wrong with the conda-packaged redis?

Steve

Hi Steve, sorry for the delayed response, have been traveling. I am not sure offhand what the problem might be. I have tested bokeh server on Ubuntu 11 but maybe not 10.04. I have cc'd the lead conda dev on this, he might have some input as well.

Bryan

···

On Dec 12, 2013, at 5:04 PM, Stephen Waterbury <[email protected]> wrote:

Just an FYI -- I just installed the latest Anaconda
(Anaconda-1.8.0-Linux-x86.sh) on Ubuntu 10.04.
Ran bokeh-server command, but it needed redis, which
was not installed. Tried 'conda install redis', which
claimed it worked (redis showed up in 'conda list'), but
bokeh-server couldn't find it -- turned out that
'import redis' also failed at the python prompt, and
there was no redis in the site-packages directory.
Then tried 'pip install redis', which worked and then
the bokeh-server started up okay.

Maybe something wrong with the conda-packaged redis?

Steve

--
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/52A9ECA3.80307%40nasa.gov\.
For more options, visit https://groups.google.com/a/continuum.io/groups/opt_out\.

Steven,

The redis conda package is just the redis server and does not include redis python bindings. Try:

  conda install redis-py

And that should make "import redis" work.

Thanks,

Bryan

···

On Dec 14, 2013, at 3:08 PM, Bryan Van de Ven <[email protected]> wrote:

Hi Steve, sorry for the delayed response, have been traveling. I am not sure offhand what the problem might be. I have tested bokeh server on Ubuntu 11 but maybe not 10.04. I have cc'd the lead conda dev on this, he might have some input as well.

Bryan

On Dec 12, 2013, at 5:04 PM, Stephen Waterbury <[email protected]> wrote:

Just an FYI -- I just installed the latest Anaconda
(Anaconda-1.8.0-Linux-x86.sh) on Ubuntu 10.04.
Ran bokeh-server command, but it needed redis, which
was not installed. Tried 'conda install redis', which
claimed it worked (redis showed up in 'conda list'), but
bokeh-server couldn't find it -- turned out that
'import redis' also failed at the python prompt, and
there was no redis in the site-packages directory.
Then tried 'pip install redis', which worked and then
the bokeh-server started up okay.

Maybe something wrong with the conda-packaged redis?

Steve

--
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/52A9ECA3.80307%40nasa.gov\.
For more options, visit https://groups.google.com/a/continuum.io/groups/opt_out\.