"Best practices" way to access a plot from Javascript

I was just curious about the “best practices” way to look up a plot from Javascript.

I am currently using bokeh.embed.components to produce Javascript and divs that I include in a static HTML document. In particular, I am not using a server, so I tend to write some Javascript to update ColumnsDataSources and whatnot. I know that it is possible to use CustomJS for this purpose, but I prefer to just write the Javascript directly as I do a lot of non-Bokeh things along with the Bokeh updates. This is all pretty straight forward once I get my hands on the plots in questions, but its not entirely clear to me how I should be doing that.

Currently, I do something along the lines of:

doc = Bokeh.documents[0];

fig = doc.get_model_by_name(“my_fig_name”);

Is this the right way to go? Is Bokeh.documents an implementation detail, or should I consider that part of the public API? Is there some other function that I should use to get my hands on the Bokeh document object from Javascript?

Thanks,

Gerard

Hi,

I am not sure these best practices always exist yet. As far using Bokeh.documents goes, I think it's probably OK and maybe the most reasonable thing for now, but I also gather that's it's maybe something real JS devs would find weird or less than optimal. BokehJS was originally mostly a hidden implementation detail. That's not exactly the case anymore, and we would love for BokehJS to be more accessible in general to people that want to use things directly from JS. But what is really needed for that to happen is input and guidance from people that have more JS experience and real use cases to solve. I am definitely not a front-end dev, experienced or otherwise. So if I were to try to define these best practices or make some API to help with things by myself, there would be a very real chance that build the wrong thing, and that's not good for anyone at all. So this is an opportunity to help by making suggestions for documented and supportable (i.e. *testable*) APIs that would be helpful to you.

Thanks,

Bryan

···

On Apr 2, 2018, at 14:17, [email protected] wrote:

I was just curious about the "best practices" way to look up a plot from Javascript.

I am currently using bokeh.embed.components to produce Javascript and divs that I include in a static HTML document. In particular, I am not using a server, so I tend to write some Javascript to update ColumnsDataSources and whatnot. I know that it is possible to use CustomJS for this purpose, but I prefer to just write the Javascript directly as I do a lot of non-Bokeh things along with the Bokeh updates. This is all pretty straight forward once I get my hands on the plots in questions, but its not entirely clear to me how I should be doing that.

Currently, I do something along the lines of:

doc = Bokeh.documents[0];
fig = doc.get_model_by_name("my_fig_name");

Is this the right way to go? Is Bokeh.documents an implementation detail, or should I consider that part of the public API? Is there some other function that I should use to get my hands on the Bokeh document object from Javascript?

Thanks,
Gerard

--
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/92e15c71-273d-4644-9624-a9098b59fb1b%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi,

···

On Mon, Apr 2, 2018 at 9:17 PM, [email protected] wrote:

I was just curious about the “best practices” way to look up a plot from Javascript.

I am currently using bokeh.embed.components to produce Javascript and divs that I include in a static HTML document. In particular, I am not using a server, so I tend to write some Javascript to update ColumnsDataSources and whatnot. I know that it is possible to use CustomJS for this purpose, but I prefer to just write the Javascript directly as I do a lot of non-Bokeh things along with the Bokeh updates. This is all pretty straight forward once I get my hands on the plots in questions, but its not entirely clear to me how I should be doing that.

Currently, I do something along the lines of:

doc = Bokeh.documents[0];

fig = doc.get_model_by_name(“my_fig_name”);

Is this the right way to go? Is Bokeh.documents an implementation detail, or should I consider that part of the public API? Is there some other function that I should use to get my hands on the Bokeh document object from Javascript?

maybe you could submit a code example of your approach (you can skip all the data and unrelated stuff; I’m just interested in the embedding code)? We have some work going on improving bokeh’s templating capabilities, so this may be useful to cover more cases with this work.

Mateusz

Thanks,

Gerard

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/92e15c71-273d-4644-9624-a9098b59fb1b%40continuum.io.

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

Also please note this existing discussion:

  Structured way to get at documents from JavaScript · Issue #3700 · bokeh/bokeh · GitHub

Thanks,

Bryan

···

On Apr 10, 2018, at 18:09, Mateusz Paprocki <[email protected]> wrote:

Hi,

On Mon, Apr 2, 2018 at 9:17 PM, <[email protected]> wrote:
I was just curious about the "best practices" way to look up a plot from Javascript.

I am currently using bokeh.embed.components to produce Javascript and divs that I include in a static HTML document. In particular, I am not using a server, so I tend to write some Javascript to update ColumnsDataSources and whatnot. I know that it is possible to use CustomJS for this purpose, but I prefer to just write the Javascript directly as I do a lot of non-Bokeh things along with the Bokeh updates. This is all pretty straight forward once I get my hands on the plots in questions, but its not entirely clear to me how I should be doing that.

Currently, I do something along the lines of:

doc = Bokeh.documents[0];
fig = doc.get_model_by_name("my_fig_name");

Is this the right way to go? Is Bokeh.documents an implementation detail, or should I consider that part of the public API? Is there some other function that I should use to get my hands on the Bokeh document object from Javascript?

maybe you could submit a code example of your approach (you can skip all the data and unrelated stuff; I'm just interested in the embedding code)? We have some work going on improving bokeh's templating capabilities, so this may be useful to cover more cases with this work.

Mateusz

Thanks,
Gerard

--
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/92e15c71-273d-4644-9624-a9098b59fb1b%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/CANFzp8hAwVKrvwNBreHo4bSS43zMNuvFzmEz_V_Oizihrqpe2Q%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.