Programmatically select inside gridmatrix

Run the following cells and it should display a gridmatrix with a table below. If a selection is made on the table, I’m currently experiencing this exception:

ValueError: Unexpected option ‘selected’ for Distribution type across all extensions. No similar options found.

How can I programmatically select inside a gridmatrix?

import holoviews as hv
import panel as pn
import param
from holoviews import opts
from bokeh.sampledata.iris import flowers
from holoviews.operation import gridmatrix
from holoviews.streams import Selection1D, Stream

hv.extension('bokeh')

print('holoviews: ', hv.__version__)
print('panel:     ', pn.__version__)
print('param:     ', param.__version__)

holoviews: 1.14.1a1
panel: 0.9.7
param: 1.9.3

iris_ds = hv.Dataset(flowers, kdims=['sepal_length','sepal_width','petal_length','petal_width'])

grid = gridmatrix(iris_ds, diagonal_type=hv.Distribution, chart_type=hv.Points).opts(
    opts.GridMatrix(shared_datasource=True, merge_tools=True),
    opts.Points(tools=['hover', 'box_select', 'lasso_select', 'tap'], active_tools=['box_select'],
                shared_datasource=True),
    opts.Distribution(shared_datasource=False, shared_axes=False))

table = hv.Table(iris_ds, kdims=['sepal_length','sepal_width','petal_length','petal_width']).opts(
    selectable=True, toolbar=None, shared_datasource=True)
select_table = Stream.define('Selected', selected=[])()
table_selected = Selection1D(source=table)

@param.depends(index=table_selected.param.index)
def reactive_grid(index):
    if len(index) != 0: 
        return grid.apply.opts(selected=index)
    else:
        return grid
    
@param.depends(selected=select_table.param.selected)
def reactive_table(selected):
    table_selected.update(index=selected)
    return table.apply.opts(selected=selected)

pn.Column(reactive_grid, reactive_table)
1 Like