Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTable does not stay sorted when the data is updated #8201

lesteve opened this issue Sep 1, 2018 · 1 comment · Fixed by #8310

DataTable does not stay sorted when the data is updated #8201

lesteve opened this issue Sep 1, 2018 · 1 comment · Fixed by #8310


Copy link

lesteve commented Sep 1, 2018

ALL software version info (bokeh, python, notebook, OS, browser, any other relevant packages)

bokeh: 0.13.0
python: 3.6.5
OS: Ubuntu 16.04
Browser: Firefox and Chromium

Description of expected behavior and the observed behavior

This is based on the example at Click on the "Experience" column to sort by Experience. Then move the slider on the left hande side that defines the salary range.

  • actual behavior: the data is not sorted anymore by Experience
  • expected behavior: the table stays sorted by Experience when you move the slider

Complete, minimal, self-contained example code that reproduces the issue

This is a copy of paste of the example at except with 10 data points.

from os.path import dirname, join

import pandas as pd

from bokeh.layouts import row, widgetbox
from bokeh.models import ColumnDataSource, CustomJS
from bokeh.models.widgets import RangeSlider, Button, DataTable, TableColumn, NumberFormatter
from import curdoc

df = pd.read_csv(join(dirname(__file__), 'salary_data.csv')).iloc[:10]

source = ColumnDataSource(data=dict())

def update():
    current = df[(df['salary'] >= slider.value[0]) & (df['salary'] <= slider.value[1])].dropna() = {
        'name'             :,
        'salary'           : current.salary,
        'years_experience' : current.years_experience,

slider = RangeSlider(title="Max Salary", start=10000, end=110000, value=(10000, 50000), step=1000, format="0,0")
slider.on_change('value', lambda attr, old, new: update())

button = Button(label="Download", button_type="success")
button.callback = CustomJS(args=dict(source=source),
                           code=open(join(dirname(__file__), "download.js")).read())

columns = [
    TableColumn(field="name", title="Employee Name"),
    TableColumn(field="salary", title="Income", formatter=NumberFormatter(format="$0,0.00")),
    TableColumn(field="years_experience", title="Experience (years)")

data_table = DataTable(source=source, columns=columns, width=800)

controls = widgetbox(slider, button)
table = widgetbox(data_table)

curdoc().add_root(row(controls, table))
curdoc().title = "Export CSV"


Side-comment: I noticed that in a dask context, I wanted the workers sorted by CPU usage (similar to htop) in the dask dashboard but the sorting disappears on the first data update.

Copy link

lesteve commented Sep 1, 2018

Here is a gif: bokeh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging a pull request may close this issue.

3 participants