[bokeh] [Q] How to access all data of selected points in CustomJS callback

The source has an attribute column_names which will give you all
the column_names as an array. You could then iterate over that
array to do whatever you need to access the data.

  I think that's what you're asking for, sorry if I've

misunderstood.

Bird

···

On 10/8/16 7:03 AM, wrote:

[email protected]

Hy,

I have the following callback:

              self.sources[i].callback =

CustomJS(args=dict(p=p,source=self.sources[i]),
code="""

var inds = cb_obj.get(‘selected’)[‘1d’].indices;

var d1 = cb_obj.get(‘data’);

var text = ‘’;

var datatext = ‘’;

if (inds.length == 1)

{

datatext = ('Point '+inds[0]);

              var data = "<p>This is 'myWindow' for Point

“+inds[0]+” : “+d1[‘Col X’][inds[0]]+”

";
              myWindow = window.open( +

encodeURIComponent(data),

              "_blank",

“width=200,height=100”);

myWindow.focus();

}

“”"

)

``

      **            Is there a way to access all columns without knowing their

column name?**

      I can't figure out what data type the cb_obj.get('data')

returns. The self.sources[i] is
a ColumnDataSource(data=self.datadict).

      I want to open a window for every selected point and

display the data of the selected point.

Thanks in advance,

Tom

  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/8abe249a-2c85-4350-adab-b8c6fd93c16b%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/8abe249a-2c85-4350-adab-b8c6fd93c16b%40continuum.io?utm_medium=email&utm_source=footer).

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


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

“data:text/html,”

Thats exactly what I needed, thank you very much.

Tom

···

Am Sonntag, 9. Oktober 2016 09:25:52 UTC+2 schrieb Sarah Bird:

  The source has an attribute column_names which will give you all

the column_names as an array. You could then iterate over that
array to do whatever you need to access the data.

  I think that's what you're asking for, sorry if I've

misunderstood.

Bird

On 10/8/16 7:03 AM, [email protected] > wrote:

Hy,

I have the following callback:

              self.sources[i].callback =

CustomJS(args=dict(p=p,source= self.sources[i]),
code="""

var inds = cb_obj.get(‘selected’)[‘1d’].indices;

var d1 = cb_obj.get(‘data’);

var text = ‘’;

var datatext = ‘’;

if (inds.length == 1)

{

datatext = ('Point '+inds[0]);

              var data = "<p>This is 'myWindow' for Point

“+inds[0]+” : “+d1[‘Col X’][inds[0]]+”

";

myWindow = window.open(“data:text/html,” +
encodeURIComponent(data),

              "_blank",

“width=200,height=100”);

myWindow.focus();

}

“”"

)

``

      **            Is there a way to access all columns without knowing their

column name?**

      I can't figure out what data type the cb_obj.get('data')

returns. The self.sources[i] is
a ColumnDataSource(data=self.datadict).

      I want to open a window for every selected point and

display the data of the selected point.

Thanks in advance,

Tom

  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/8abe249a-2c85-4350-adab-b8c6fd93c16b%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/8abe249a-2c85-4350-adab-b8c6fd93c16b%40continuum.io?utm_medium=email&utm_source=footer).

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


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px">
    ](http://continuum.io)