holoviz / hvplot

A high-level plotting API for pandas, dask, xarray, and networkx built on HoloViews
https://hvplot.holoviz.org
BSD 3-Clause "New" or "Revised" License
1.15k stars 108 forks source link

Can't use select widget to update interactive table #684

Open gawells opened 3 years ago

gawells commented 3 years ago

Software (anaconda in windows 10/11): panel: 0.12.4 holoviews: 1.14.6 hvplot: 0.7.3 python: 3.9.7

I'm trying to use the select widget to choose which column appears in an interactive table. This works when returning a dataframe:

import panel as pn
from bokeh.sampledata.autompg import autompg
pn.extension()

s = pn.widgets.Select(options=list(autompg.columns))
def t(col1): return autompg[[col1,'cyl']]

pn.Column(s, pn.bind(t, col1=s))

But not for an interactive table:

import panel as pn, hvplot.pandas
from bokeh.sampledata.autompg import autompg
pn.extension()

s = pn.widgets.Select(options=list(autompg.columns))
autompg = autompg.interactive()
def t(col1): return autompg[[col1,'cyl']]

pn.Column(s, pn.bind(t, col1=s))

The reason I'm using the latter is because I also want to combine it linked selections as described here.

philippjfr commented 2 years ago

Not quite sure what's up with that but this works:

s = pn.widgets.Select(options=list(autompg.columns))
autompg = autompg.interactive()

def t(col1): 
    return pn.pane.Interactive(autompg[[col1,'cyl']])
philippjfr commented 2 years ago

Appears to be a bug in .interactive itself. The process that is used to discover how to render the component seems to leave the Interactive object in a weird state where it renders as something other than what we want.

maximlt commented 2 years ago

I can reproduce.