On Oct 15, 2017, at 14:38, Dan Kovacek <[email protected]> wrote:
From the docs I understand that "CustomJS callbacks can be attached to property change events on any Bokeh model". Are Div and PreText considered models?
Since PreText has a 'text' attribute, Should be able to call pretext_object.on_change('text', callback)?
I tried the following to no avail:
results = PreText(text='test')
toggle_pulse = dict()
toggle_pulse = CustomJS(args=toggle_pulse, code='''
var this_id = cb_obj.attributes['id'];
var input_div = document.getElementById(this_id);
var target_div = $(input_div).parent().parent().siblings()[0];
target_div.style.display = 'none';
''')
#(another set of functions calculates results and updates the pretext results object)
results.on_change('text', toggle_pulse)
Also, what's protocol on responding to old posts? Is there a 'too old' where the latest Bokeh version is too old to make the original post relevant, or is it better for searching purposes to use related threads whenever possible?
Thanks!
Dan
On Friday, August 5, 2016 at 5:59:41 AM UTC-7, Sarah Bird wrote:
Bokeh in general needs events to fire actions. The server will accept "periodic callbacks" and from that you should be able to read the width and height.
If you're just putting some JS on your page to inspect your bokeh items you can use the `Bokeh.index` to find your plot and start inspecting it.
So I think you could build a function like that that uses Bokeh.index to get at your bokeh objects and then call it at will.
On 8/4/16 8:35 AM, Bill wrote:
Thank you both for the help. If I understand, I can use .on_change method to call python function, and .callback attribute to call CustomJS?
Actually I wanted to do something a little different. I am trying to get the width and height of a plot using the following JS. I found a solution online which is to attach this JS to x_range.callback. However, I am wondering if there is a way to call this JS directly without needing to change x range first.
Hope this make sense. Thank you.
dims_jscode = """
var update_dims = function () {
var new_data = {};
new_data['height'] = [plot.plot_canvas.frame.get('height')];
new_data['width'] = [plot.plot_canvas.frame.get('width')];
dims.set('data', new_data);
};
if (typeof throttle != 'undefined' && throttle != null) {
clearTimeout(throttle);
}
throttle = setTimeout(update_dims, 100, "replace");
"""
dims = ColumnDataSource(dict(width=[plot_width], height=[plot_height] ))
fig.x_range.callback = CustomJS(code=dims_jscode, args=dict(plot=fig, dims=dims))
On Thursday, August 4, 2016 at 9:35:48 PM UTC+8, Bryan Van de ven wrote:
I would only keep in mind: CustomJS callbacks will execute in the browser, essentially immediately, while any python callback will execute in a Bokeh server after a network protocol exchange. So "same time" has to be interpreted with some looseness. If you have two unrelated tasks, things should be fine. If you need to enforce some ordering or synchronization between the two types of callbacks, that's probably not possible (except that the CustomJS will "probably" always execute first, but no guarantees there either).
Thanks,
Bryan
> On Aug 4, 2016, at 8:05 AM, Sarah Bird - Continuum <[email protected]> wrote:
>
> Try adding a seperate CustomJS callback: bokeh.pydata.org/en/latest/docs/user_guide/interaction/callbacks.html
>
> On 8/4/16 1:33 AM, Bill wrote:
>> Thank you for reading. I googled a lot but cannot find an answer, so I might try my luck here.
>>
>> I am running a bokeh server. When a widget (say, a button) is clicked, a python function is triggered. However, I want to run some javascript code at the same time. Is it possible? Thanks for any advice.
>> --
>> 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 bokeh+un...@continuum.io.
>> To post to this group, send email to bo...@continuum.io.
>> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4c11b432-af5a-4d39-80b0-2ddc2b6e97fc%40continuum.io\.
>> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
>
> --
> Sarah Bird
> Developer, Bokeh
>
>
>
>
> --
> 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 bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/e4e816d4-560f-507f-73f7-0415430e1661%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 bokeh+un...@continuum.io.
To post to this group, send email to bo...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/81999c26-c871-463c-b1e3-49494ea325bb%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
--
Sarah Bird
Developer, Bokeh
--
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/0929c4ae-b53b-4ec6-bed3-479770092a6d%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.