What are you trying to do?
I am trying to link the selection from stacked_varea
plot to a DataTable
widget
i.e. the selection from any one side will be hightlighted on the other widget
What have you tried that did NOT work as expected?
What I have tried
I have tried to convert the “data_table_plot” example from a scatter plot to a stacked varea plot
the “data_table_plot” example:
What is not working
- selection does not seem to work in the (stacked_area) plot
- if selection is made in the
DataTable
widget, it does not reflect (highlight) on the plot widget
A minimal, reproducible example:
from bokeh.layouts import column
from bokeh.models import (
ColumnDataSource,
DataTable,
HoverTool,
IntEditor,
NumberEditor,
NumberFormatter,
SelectEditor,
StringEditor,
StringFormatter,
TableColumn,
)
from bokeh.plotting import figure, show
from bokeh.sampledata.autompg2 import autompg2 as mpg
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()),
]
data_table = DataTable(
source=source,
columns=columns,
editable=True,
width=800,
index_position=-1,
index_header="row index",
index_width=60,
)
p = figure(
width=800,
height=300,
tools="pan,wheel_zoom,xbox_select,reset",
active_drag="xbox_select",
)
p.varea_stack(
stackers=["cty", "hwy"],
x="index",
source=source,
)
show(column(p, data_table))
Related issues
I have read from other post that a line is render as a single glyph, so no individual data point glyph can be selected.
I would guess area is render similarly?
However, the docs of varea https://docs.bokeh.org/en/latest/docs/reference/plotting/figure.html#bokeh.plotting.figure.varea
also said
It is also possible to set the color and alpha parameters of extra glyphs for selection, nonselection, hover, or muted. To do so, add the relevant prefix to any visual parameter. For example, pass
nonselection_alpha
to set the line and fill alpha for nonselect, orhover_fill_alpha
to set the fill alpha for hover. …
so I am a bit confused.
another possibily related issue
https://discourse.bokeh.org/t/how-to-highlight-a-selected-area-in-the-graph-and-finding-max-min-values-with-using-bokeh/9276
Thank you in advance.
(There is a 2 link max. limit for new users, so unfortunately have to put some links as raw literal to work around it.)