Closed
Description
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.