bokeh interaction of two datatables

Hello,

I did take a look at bokeh the last weeks and like it a lot.

At the moment I try to write a small app, where I would like to create a few plots based on the selection of two DataTables.

Before
this, I created a small test case, where I added two DataTables and one
Button (see attached example; run with : bokeh serve datatable_3_v1.py --show ).

The first idea was to react to the button on_click event and to get the selected data to the console. This works quite good.

Though, I am looking for a way to update the second table based on the selected rows from the first table.

E.g. I select in the 1st table row number 3 and 5.

After the button press, in the 2nd table only the rows 3 and 5 should be shown.

It would be great if you have a suggestion to me!?

As
another step I would like to remove the button and would like to update
the 2nd table as soon as I made some selection in the 1st table.

Best Regards

Fabian

datatable_3_v1.py (2.46 KB)

Hi all,
sorry for bother you… it would be very nice if you have any hint how to proceed.

Please let me know, if the question was too confusing.

Best Regards

Fabian

···

On Mon, Jun 12, 2017 at 6:31 AM, ‘Fabian Braennstroem’ via Bokeh Discussion - Public [email protected] wrote:

Hello,

I did take a look at bokeh the last weeks and like it a lot.

At the moment I try to write a small app, where I would like to create a few plots based on the selection of two DataTables.

Before
this, I created a small test case, where I added two DataTables and one
Button (see attached example; run with : bokeh serve datatable_3_v1.py --show ).

The first idea was to react to the button on_click event and to get the selected data to the console. This works quite good.

Though, I am looking for a way to update the second table based on the selected rows from the first table.

E.g. I select in the 1st table row number 3 and 5.

After the button press, in the 2nd table only the rows 3 and 5 should be shown.

It would be great if you have a suggestion to me!?

As
another step I would like to remove the button and would like to update
the 2nd table as soon as I made some selection in the 1st table.

Best Regards

Fabian

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/4fee9f13-78fd-4d8e-8b30-cd2af84dc585%40continuum.io.

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

Regards!
Fabian

If I understand your question correctly, this code does what you want:

from datetime import date
from random import randint

from [bokeh.io](http://bokeh.io) import curdoc
from bokeh.layouts import column
from bokeh.models import Button, ColumnDataSource, DataTable, DateFormatter, TableColumn
from bokeh.plotting import figure

data1 = dict(dates=[date(2014, 3, i+1) for i in range(10)],
             downloads=[randint(0, 100) for i in range(10)])
source1 = ColumnDataSource(data=data1)

data2 = dict(dates=[date(2014, 3, i+1) for i in range(10)],
             downloads=[randint(0, 100) for i in range(10)])
source2 = ColumnDataSource(data=data2)

columns = [TableColumn(field="dates", title="Date",
           formatter=DateFormatter()),
           TableColumn(field="downloads", title="Downloads")]

table1 = DataTable(source=source1, columns=columns, width=400, height=280, editable=True)
table2 = DataTable(source=source2, columns=columns, width=400, height=280, editable=True)

def callback():
    inds = source1.selected['1d']['indices']
    new_data = dict(
        dates=[data2['dates'][i] for i in inds],
        downloads=[data2['downloads'][i] for i in inds],
    )
    source2.data = new_data

button = Button(label="Press Me")
button.on_click(callback)

curdoc().add_root(column(button, table1, table2))

It results in this for example, after pressing the button:

···

On Jun 19, 2017, at 04:04, ‘Fabian Braennstroem’ via Bokeh Discussion - Public [email protected] wrote:

Hi all,
sorry for bother you… it would be very nice if you have any hint how to proceed.
Please let me know, if the question was too confusing.
Best Regards
Fabian

On Mon, Jun 12, 2017 at 6:31 AM, ‘Fabian Braennstroem’ via Bokeh Discussion - Public [email protected] wrote:
Hello,

I did take a look at bokeh the last weeks and like it a lot.

At the moment I try to write a small app, where I would like to create a few plots based on the selection of two DataTables.

Before this, I created a small test case, where I added two DataTables and one Button (see attached example; run with : bokeh serve datatable_3_v1.py --show ).

The first idea was to react to the button on_click event and to get the selected data to the console. This works quite good.

Though, I am looking for a way to update the second table based on the selected rows from the first table.

E.g. I select in the 1st table row number 3 and 5.
After the button press, in the 2nd table only the rows 3 and 5 should be shown.

It would be great if you have a suggestion to me!?
As another step I would like to remove the button and would like to update the 2nd table as soon as I made some selection in the 1st table.

Best Regards
Fabian


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/4fee9f13-78fd-4d8e-8b30-cd2af84dc585%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


Regards!
Fabian


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/CAGzVTv%2BCArpOX7sg7VubFE7aDRPDZnMNyP1SK5HdCNA9VOW0wA%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hello Bryan,

  thank you very much for the help! Yes, this is what I tryied to

do.

  It seems, that it is important to directly change the

source2.data and not only source2.

Thank you!

Fabian

···

On 23.06.2017 04:03, Bryan Van de ven
wrote:

  If I

understand your question correctly, this code does what you want:

from datetime import date

        from random import randint



        from [bokeh.io](http://bokeh.io) import curdoc

        from bokeh.layouts import column

        from bokeh.models import Button, ColumnDataSource,

DataTable, DateFormatter, TableColumn

        from bokeh.plotting import figure



        data1 = dict(dates=[date(2014, 3, i+1) for i in range(10)],

                     downloads=[randint(0, 100) for i in range(10)])

        source1 = ColumnDataSource(data=data1)



        data2 = dict(dates=[date(2014, 3, i+1) for i in range(10)],

                     downloads=[randint(0, 100) for i in range(10)])

        source2 = ColumnDataSource(data=data2)



        columns = [TableColumn(field="dates", title="Date",

                   formatter=DateFormatter()),

                   TableColumn(field="downloads",

title=“Downloads”)]

        table1 = DataTable(source=source1, columns=columns,

width=400, height=280, editable=True)

        table2 = DataTable(source=source2, columns=columns,

width=400, height=280, editable=True)

        def callback():

            inds = source1.selected['1d']['indices']

            new_data = dict(

                dates=[data2['dates'][i] for i in inds],

                downloads=[data2['downloads'][i] for i in inds],

            )

            source2.data = new_data



        button = Button(label="Press Me")

        button.on_click(callback)



        curdoc().add_root(column(button, table1, table2))
    It results in this for example, after pressing the

button:

      On Jun 19, 2017, at 04:04,

‘Fabian Braennstroem’ via Bokeh Discussion - Public [email protected] wrote:

      Hi all,

      sorry for bother you... it would be very nice if you have any

hint how to proceed.

      Please let me know, if the question was too confusing.

      Best Regards

      Fabian



      On Mon, Jun 12, 2017 at 6:31 AM, 'Fabian Braennstroem' via

Bokeh Discussion - Public [email protected] wrote:

      Hello,



      I did take a look at bokeh the last weeks and like it a lot.



      At the moment I try to write a small app, where I would like

to create a few plots based on the selection of two
DataTables.

      Before this, I created a small test case, where I added two

DataTables and one Button (see attached example; run with :
bokeh serve datatable_3_v1.py --show ).

      The first idea was to react to the button on_click event and

to get the selected data to the console. This works quite
good.

      Though, I am looking for a way to update the second table

based on the selected rows from the first table.

      E.g. I select in the 1st table row number 3 and 5. 

      After the button press,  in the 2nd table only the rows 3 and

5 should be shown.

      It would be great if you have a suggestion to me!?

      As another step I would like to remove the button and would

like to update the 2nd table as soon as I made some selection
in the 1st table.

      Best Regards

      Fabian





      -- 

      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 .
To post to this group, send email to .
To view this discussion on the web
visit .
For more options,
visit .

Regards!
Fabian

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 .
To post to this group, send email to .
To view this discussion on the web
visit .
For more options,
visit .

  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/970AA22C-D323-4326-B54F-5C21D276F202%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/970AA22C-D323-4326-B54F-5C21D276F202%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).

[email protected]
[email protected]
https://groups.google.com/a/continuum.io/d/msgid/bokeh/4fee9f13-78fd-4d8e-8b30-cd2af84dc585%40continuum.io
https://groups.google.com/a/continuum.io/d/optout

[email protected]
[email protected]
https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAGzVTv%2BCArpOX7sg7VubFE7aDRPDZnMNyP1SK5HdCNA9VOW0wA%40mail.gmail.com
https://groups.google.com/a/continuum.io/d/optout