4

I am building a dashboard for a JSON REST API and I wanted to get a list of elements from the server, visualize it in a table, then interact with it.

I modified Bokeh Data Table Example to use an AjaxDataSource instead of a ColumnDataSource.

The resulting code is this:

from datetime import date
from random import randint

from bokeh.models import AjaxDataSource
from bokeh.models.widgets import DataTable, DateFormatter, TableColumn
from bokeh.models.layouts import WidgetBox
from bokeh.plotting import show

source=AjaxDataSource(data_url="http://127.0.0.1:8000/dates", polling_interval=200)

#############
# Create data dict for the source, could be empty, filled with random data for testing
#############

source.data=dict( dates=[date(2017, 2, i+1) for i in range(10)],
        downloads=[randint(0, 100) for i in range(10)])

columns = [
        TableColumn(field="dates", title="Date", formatter=DateFormatter()),
        TableColumn(field="downloads", title="Downloads"),
    ]
data_table = DataTable(source=source, columns=columns, width=400, height=280)

show(WidgetBox(data_table))

Unfortunately, the server is not contacted at all and the table still shows the sample data I filled in to see what happened.

If I use a plot with an AjaxDataSource, instead, it's updating properly, contacting the server every polling interval

Metiu
  • 1,677
  • 2
  • 16
  • 24

1 Answers1

0

I had the exact same problem. This is no longer an issue if you use bokeh version 0.13.0. After I upgraded, it worked. Please see the last comment in this site. https://github.com/bokeh/bokeh/issues/7937

Hugo Alain Oliva
  • 237
  • 1
  • 10