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

Closed
lesteve opened this Issue Sep 1, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@lesteve
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 https://demo.bokehplots.com/apps/export_csv. 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 https://demo.bokehplots.com/apps/export_csv 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 bokeh.io 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()
    source.data = {
        'name'             : current.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"

update()

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.

@mattpap mattpap added this to the short-term milestone Sep 1, 2018

@lesteve

This comment has been minimized.

Copy link
Author

lesteve commented Sep 1, 2018

Here is a gif: bokeh

@bryevdv bryevdv referenced this issue Oct 9, 2018

Merged

DataTable data model fixes #8310

6 of 6 tasks complete

@bryevdv bryevdv modified the milestones: short-term, 1.0 Oct 11, 2018

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