On Dec 14, 2016, at 5:12 AM, Ola Skavhaug <[email protected]> wrote:
Hi, thanks for your quick reply.
I absolutely understand the difference between the javascript running in the browser, and the bokeh server communicating with bokeh.js, so in order to get this to work, I need to run the server.
I have tried to follow the example you provided, but I am still not able to figure out what kind of event that is triggered by the BoxZoomTool. At least, after using the zoom tool, a don't get a "selected" event.
What I'm doing is:
f = figure()
l1 = f.line("x", "y", data_source)
def my_callback(attrname, old, new):
print(attrname, old, new)
l1.data_source.on_change("selected", my_callback)
Using the BoxZoomTool does not give me any printouts. Changing the data, however, does (through the use of a Select widget with a corresponding on_change("value", select_callback) callback handler).
Best,
Ola Skavhaug
On Tue, Dec 13, 2016 at 5:13 PM, Bryan Van de Ven <[email protected]> wrote:
Hi,
Yes, just to be clear up front: only when using a Bokeh server app. Browsers have no ability to run python code, so if you want real python code run in response to some event (e.g. a selection) then there has to be a place for that python code to run. The bokeh server is that place.
Selections are stored on data sources, so you'd add an .on_change to a data source object. There is a deployed demo example that shows python code responding to a selection here:
https://demo.bokehplots.com/apps/selection_histogram
Make a selection and see the histograms on the side be updated. The code for that example is here:
https://github.com/bokeh/bokeh/blob/master/examples/app/selection_histogram.py
Note hat link is to GitHub "master" branch, so if you are using and older version of Bokeh you might have to check out a tag corresponding to your version.
Thanks,
Bryan
> On Dec 13, 2016, at 10:06 AM, Ola Skavhaug <[email protected]> wrote:
>
> Hi list,
>
> I am very new to Bokeh, so please be kind to me if my question does not make sense
>
> My question is if it is possible to construct a BoxZoomTool that will trigger a callback to Python when an area is selected. Something along the following lines:
>
> def my_bzt_callback(attrname, old, new):
> # Update data
> pass
>
> bzt = BoxZoomTool()
> bzt.on_change("some_event_indicating_selection_is_made", my_bzt_callback)
> tools = [bzt]
> f = figure(tools=tools)
>
> I want this behaviour as I am visualizing time series data of a certain, very high frequency, and based on the range of the selection, want to do a frequenzy conversion server side to minimize the data sendt to the client side.
>
> I am not able to find out if this is even possible in a simple way, and if it is, what kind of event I would use as first arg to the on_change method.
>
> Best,
> Ola Skavhaug
>
> --
> 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/16004570-8594-4fcb-8bea-2c761deaa207%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/A8DD3338-B6C2-49C0-ADDB-0E68A5B7AF73%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/CAOS-rS78odxE9fwrat%2BhGPQ9fLiiuBzVM9eaK-OrmJJKv6JRBA%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.