I have a quite strange and I think difficult problem with callbacks. Let me first describe how I am creating my plots and series. So, I am creating plots with many lines (one, two,…, n - dynamic generation) with markers in certain points. For each line I have different source - ColumnDataSource, and also I have different sourcers for markers as for each line i creating two types of markers. Someone could ask why I use many sources, so the answer is quite simple - each set of markers can store different data, which are used by HoverTools (n instances).
Now I want to add callback which allow me to fill some forms in html by data from source assigned to selected marker. I found huge problem and I do not know how to resolve it. I want to have one TapTool, which call JS function definied in CustomJS for selected marker. The main problem is to get information about source dynamically through clicked marker.
Has anybody knowledge whether is it possible or not? I am aware that my plot generation func. may be complex, but i need to have a lot of data presented directly on what plot.
I have a quite strange and I think difficult problem with callbacks. Let me first describe how I am creating my plots and series. So, I am creating plots with many lines (one, two,…, n - dynamic generation) with markers in certain points. For each line I have different source - ColumnDataSource, and also I have different sourcers for markers as for each line i creating two types of markers. Someone could ask why I use many sources, so the answer is quite simple - each set of markers can store different data, which are used by HoverTools (n instances).
Now I want to add callback which allow me to fill some forms in html by data from source assigned to selected marker. I found huge problem and I do not know how to resolve it. I want to have one TapTool, which call JS function definied in CustomJS for selected marker. The main problem is to get information about source dynamically through clicked marker.
Has anybody knowledge whether is it possible or not? I am aware that my plot generation func. may be complex, but i need to have a lot of data presented directly on what plot.
if I understand the problem correctly then yes. CustomJS creates a JS function that takes n user-supplied arguments (I presume n=0 in your case), two special arguments cb_obj and cb_data, which understanding varies depending on the context and require which is a reference to require() function for importing modules. In the case of TapTool cb_obj is a reference to the data source used by the selected glyph and cb_data is null. So you should use cb_obj.get('data') in your code.
Mateusz
Best regards
Adam
–
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].
Thank you for your reply. I tried to use cb_obj variable, but to be honest it returns just all source for clicked marker type. I need to go a bit deeper and get information about data assigned to clicked marker. Do you know how can I achieve it?
···
On Monday, January 25, 2016 at 5:49:27 PM UTC+1, mateusz.paprocki wrote:
I have a quite strange and I think difficult problem with callbacks. Let me first describe how I am creating my plots and series. So, I am creating plots with many lines (one, two,…, n - dynamic generation) with markers in certain points. For each line I have different source - ColumnDataSource, and also I have different sourcers for markers as for each line i creating two types of markers. Someone could ask why I use many sources, so the answer is quite simple - each set of markers can store different data, which are used by HoverTools (n instances).
Now I want to add callback which allow me to fill some forms in html by data from source assigned to selected marker. I found huge problem and I do not know how to resolve it. I want to have one TapTool, which call JS function definied in CustomJS for selected marker. The main problem is to get information about source dynamically through clicked marker.
Has anybody knowledge whether is it possible or not? I am aware that my plot generation func. may be complex, but i need to have a lot of data presented directly on what plot.
if I understand the problem correctly then yes. CustomJS creates a JS function that takes n user-supplied arguments (I presume n=0 in your case), two special arguments cb_obj and cb_data, which understanding varies depending on the context and require which is a reference to require() function for importing modules. In the case of TapTool cb_obj is a reference to the data source used by the selected glyph and cb_data is null. So you should use cb_obj.get('data') in your code.
Mateusz
Best regards
Adam
–
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].
Thank you for your reply. I tried to use cb_obj variable, but to be honest it returns just all source for clicked marker type. I need to go a bit deeper and get information about data assigned to clicked marker. Do you know how can I achieve it?
You need to get the "selected" indices off the data source (i.e. the indices of the glyphs that were clicked). This code might be instructive:
I have a quite strange and I think difficult problem with callbacks. Let me first describe how I am creating my plots and series. So, I am creating plots with many lines (one, two,..., n - dynamic generation) with markers in certain points. For each line I have different source - ColumnDataSource, and also I have different sourcers for markers as for each line i creating two types of markers. Someone could ask why I use many sources, so the answer is quite simple - each set of markers can store different data, which are used by HoverTools (n instances).
Now I want to add callback which allow me to fill some forms in html by data from source assigned to selected marker. I found huge problem and I do not know how to resolve it. I want to have one TapTool, which call JS function definied in CustomJS for selected marker. The main problem is to get information about source dynamically through clicked marker.
Has anybody knowledge whether is it possible or not? I am aware that my plot generation func. may be complex, but i need to have a lot of data presented directly on what plot.
if I understand the problem correctly then yes. CustomJS creates a JS function that takes n user-supplied arguments (I presume n=0 in your case), two special arguments cb_obj and cb_data, which understanding varies depending on the context and require which is a reference to require() function for importing modules. In the case of TapTool cb_obj is a reference to the data source used by the selected glyph and cb_data is null. So you should use `cb_obj.get('data')` in your code.
Thanks a lot! Could you also answer on below questions?
Is there any documentation with params for cb_obj and cb_data ?
When I click on a marker i am retrieving 3 arrays - two empty, one with data (my plot has 3 series with 3 sources). Is there any possibility to get only data about clicked marker (non empty array)?
Adam
···
On Tuesday, January 26, 2016 at 7:47:50 PM UTC+1, Bryan Van de ven wrote:
On Jan 26, 2016, at 1:36 AM, adam.p…@onet.eu wrote:
Hi Mateusz,
Thank you for your reply. I tried to use cb_obj variable, but to be honest it returns just all source for clicked marker type. I need to go a bit deeper and get information about data assigned to clicked marker. Do you know how can I achieve it?
You need to get the “selected” indices off the data source (i.e. the indices of the glyphs that were clicked). This code might be instructive:
I have a quite strange and I think difficult problem with callbacks. Let me first describe how I am creating my plots and series. So, I am creating plots with many lines (one, two,…, n - dynamic generation) with markers in certain points. For each line I have different source - ColumnDataSource, and also I have different sourcers for markers as for each line i creating two types of markers. Someone could ask why I use many sources, so the answer is quite simple - each set of markers can store different data, which are used by HoverTools (n instances).
Now I want to add callback which allow me to fill some forms in html by data from source assigned to selected marker. I found huge problem and I do not know how to resolve it. I want to have one TapTool, which call JS function definied in CustomJS for selected marker. The main problem is to get information about source dynamically through clicked marker.
Has anybody knowledge whether is it possible or not? I am aware that my plot generation func. may be complex, but i need to have a lot of data presented directly on what plot.
if I understand the problem correctly then yes. CustomJS creates a JS function that takes n user-supplied arguments (I presume n=0 in your case), two special arguments cb_obj and cb_data, which understanding varies depending on the context and require which is a reference to require() function for importing modules. In the case of TapTool cb_obj is a reference to the data source used by the selected glyph and cb_data is null. So you should use cb_obj.get('data') in your code.
Mateusz
Best regards
Adam
–
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].
Thanks a lot! Could you also answer on below questions?
1. Is there any documentation with params for cb_obj and cb_data ?
2. When I click on a marker i am retrieving 3 arrays - two empty, one
with data (my plot has 3 series with 3 sources). Is there any
possibility to get only data about clicked marker (non empty array)?
Adam
On Tuesday, January 26, 2016 at 7:47:50 PM UTC+1, Bryan Van de ven wrote:
> On Jan 26, 2016, at 1:36 AM, adam.p...@onet.eu <javascript:> wrote:
>
> Hi Mateusz,
>
> Thank you for your reply. I tried to use cb_obj variable, but to
be honest it returns just all source for clicked marker type. I need
to go a bit deeper and get information about data assigned to
clicked marker. Do you know how can I achieve it?
You need to get the "selected" indices off the data source (i.e. the
indices of the glyphs that were clicked). This code might be
instructive:
> On Monday, January 25, 2016 at 5:49:27 PM UTC+1, mateusz.paprocki > wrote:
> Hi,
>
> On Mon, Jan 25, 2016 at 4:51 PM, <[email protected]> wrote:
> Hello,
>
> I have a quite strange and I think difficult problem with
callbacks. Let me first describe how I am creating my plots and
series. So, I am creating plots with many lines (one, two,..., n -
dynamic generation) with markers in certain points. For each line I
have different source - ColumnDataSource, and also I have different
sourcers for markers as for each line i creating two types of
markers. Someone could ask why I use many sources, so the answer is
quite simple - each set of markers can store different data, which
are used by HoverTools (n instances).
>
> Now I want to add callback which allow me to fill some forms in
html by data from source assigned to selected marker. I found huge
problem and I do not know how to resolve it. I want to have one
TapTool, which call JS function definied in CustomJS for selected
marker. The main problem is to get information about source
dynamically through clicked marker.
>
> Has anybody knowledge whether is it possible or not? I am aware
that my plot generation func. may be complex, but i need to have a
lot of data presented directly on what plot.
>
> if I understand the problem correctly then yes. CustomJS creates a
JS function that takes n user-supplied arguments (I presume n=0 in
your case), two special arguments cb_obj and cb_data, which
understanding varies depending on the context and require which is a
reference to require() function for importing modules. In the case
of TapTool cb_obj is a reference to the data source used by the
selected glyph and cb_data is null. So you should use
`cb_obj.get('data')` in your code.
>
> Mateusz
>
>
> Best regards
> Adam
>
> --
> 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/61ddcfd4-f8e9-4f2b-92bf-058bf182a15c%40continuum.io
<https://groups.google.com/a/continuum.io/d/msgid/bokeh/61ddcfd4-f8e9-4f2b-92bf-058bf182a15c%40continuum.io>\.