bokeh: CheckboxEditor in DataTable does not display value without focus
Using the CheckboxEditor in a DataTable the value of the field (checked or unchecked) does not display unless the cell has focus (by double-clicking it).
- In Chome, the checkbox appears off center and is not toggleable.
- In Firefox, the checkbox appears centered and is toggleable.
- In both browsers the value is only observable by double-clicking the cell.
Firefox:

Chrome:

I expected to see a checkbox in each cell, whether or not it was selected.
Here’s code that shows the problem. Runs in Jupyter notebook.
from bokeh.plotting import output_notebook
output_notebook()
from bokeh.io import vplot
from bokeh.models import ColumnDataSource, DataRange1d, Plot, LinearAxis, Grid, Circle, HoverTool, BoxSelectTool
from bokeh.models.widgets import (DataTable, TableColumn,
StringFormatter, NumberFormatter, BooleanFormatter,
StringEditor, IntEditor, NumberEditor, SelectEditor, CheckboxEditor)
from bokeh.plotting import show
from bokeh.sampledata.autompg2 import autompg2 as mpg
# add a boolean column
mpg['efficient'] = mpg['hwy'] > mpg['hwy'].mean()
source = ColumnDataSource(mpg)
manufacturers = sorted(mpg["manufacturer"].unique())
models = sorted(mpg["model"].unique())
transmissions = sorted(mpg["trans"].unique())
drives = sorted(mpg["drv"].unique())
classes = sorted(mpg["class"].unique())
columns = [
TableColumn(field="manufacturer", title="Manufacturer", editor=SelectEditor(options=manufacturers), formatter=StringFormatter(font_style="bold")),
TableColumn(field="model", title="Model", editor=StringEditor(completions=models)),
TableColumn(field="displ", title="Displacement", editor=NumberEditor(step=0.1), formatter=NumberFormatter(format="0.0")),
TableColumn(field="year", title="Year", editor=IntEditor()),
TableColumn(field="cyl", title="Cylinders", editor=IntEditor()),
TableColumn(field="trans", title="Transmission", editor=SelectEditor(options=transmissions)),
TableColumn(field="drv", title="Drive", editor=SelectEditor(options=drives)),
TableColumn(field="class", title="Class", editor=SelectEditor(options=classes)),
TableColumn(field="cty", title="City MPG", editor=IntEditor()),
TableColumn(field="hwy", title="Highway MPG", editor=IntEditor()),
TableColumn(field="efficient", title="Efficient", editor=CheckboxEditor(), formatter=BooleanFormatter(icon='check')),
]
data_table = DataTable(source=source, columns=columns, editable=True)
plot = Plot(title=None, x_range= DataRange1d(), y_range=DataRange1d(), plot_width=1000, plot_height=300)
# Set up x & y axis
plot.add_layout(LinearAxis(), 'below')
yaxis = LinearAxis()
plot.add_layout(yaxis, 'left')
plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))
# Add Glyphs
cty_glyph = Circle(x="index", y="cty", fill_color="#396285", size=8, fill_alpha=0.5, line_alpha=0.5)
hwy_glyph = Circle(x="index", y="hwy", fill_color="#CE603D", size=8, fill_alpha=0.5, line_alpha=0.5)
cty = plot.add_glyph(source, cty_glyph)
hwy = plot.add_glyph(source, hwy_glyph)
# Add the tools
tooltips = [
("Manufacturer", "@manufacturer"),
("Model", "@model"),
("Displacement", "@displ"),
("Year", "@year"),
("Cylinders", "@cyl"),
("Transmission", "@trans"),
("Drive", "@drv"),
("Class", "@class"),
]
cty_hover_tool = HoverTool(renderers=[cty], tooltips=tooltips + [("City MPG", "@cty")])
hwy_hover_tool = HoverTool(renderers=[hwy], tooltips=tooltips + [("Highway MPG", "@hwy")])
select_tool = BoxSelectTool(renderers=[cty, hwy], dimensions=['width'])
plot.add_tools(cty_hover_tool, hwy_hover_tool, select_tool)
layout = vplot(plot, data_table)
show(layout)
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 3
- Comments: 15 (10 by maintainers)
as a workaround
this snippet looks like this