Link Table and Curves

How do I link a hv.Table and hv.Curve such that whenever user selects a row in the table, the hv.Curve updates?

import holoviews as hv
import panel as pn
import pandas as pd

pn.extension("tabulator")
hv.extension("bokeh")

df = pd.DataFrame({"x": [0, 1, 2], "y": [3, 4, 5]})

table = pn.widgets.Tabulator(value=df, selection=df.index.tolist())

def plot(selection):
    sub_df = df.iloc[selection]
    return hv.Scatter(sub_df, "x", "y").opts(size=25)

pn.Row(table, hv.DynamicMap(plot, streams=[table.param.selection]))

image

**Replace Scatter with Curve (but in this case, because there’s a break in the points, it shows nothing with Curve if you select only one point so I demonstrated with Scatter)

2 Likes

Thank you! Exactly what I was looking for. But I was trying with holoviews linked streams.

Just curious why there is a lag ~1s in updating the curve, even for a small dataframe?

1 Like

It’s immediate for me. Maybe restart kernel / update panel/holoviews?

It was a collab thing. I added pn.extension(comms='colab') and it seems to render faster.