Example of using holoviews TapStream with Panel

is there an example of using holoviews TapStream and panel? or something similar to using any stream and panel

Hi @ahuang11

Welcome to the community.

I don’t have an example using TapStream yet. But I have one using using RangeXY. You can find it as the KickStarterDashboard in the gallery at awesome-panel.org.

The code is here https://github.com/MarcSkovMadsen/awesome-panel/blob/master/src/pages/gallery/kickstarter_dashboard/main.py

1 Like

Here is a minimal example using the tap stream:

import panel as pn
import holoviews as hv


points = hv.Points([])
stream = hv.streams.Tap(source=points, x=np.nan, y=np.nan)

@pn.depends(stream.param.x, stream.param.y)
def location(x, y):
    return pn.pane.Str(f'Click at {x:.2f}, {y:.2f}', width=200)

pn.Row(points, location)


I think this would be useful in the docs as I’ve run into this several times and this example is much simpler than the Tap example in the holoviews docs (http://holoviews.org/reference/streams/bokeh/Tap.html). Is this something the Holoviz team would like to see added to docs? If so, let me know where and I can work on that.

1 Like

An example using the parameters API would be even better…

It took me longer then I would feel proud to say, so hoping it would help others:

Panel/Parameters/holoviews stream addition for the User Guide::Parameterized Classes::MPGExplorer example:

import param
import hvplot.pandas
from bokeh.sampledata.autompg import autompg

import panel as pn

columns = list(autompg.columns[:-2])

class MPGExplorer(param.Parameterized):

    x = param.Selector(objects=columns)
    y = param.Selector(default='hp', objects=columns)
    color = param.Color(default='#0f0f0f')
    tap = hv.streams.SingleTap()       # Source will be linked later in the dynamic map

    @param.depends('x', 'y', 'color')
    def plot(self):
        scatter = autompg.hvplot.scatter(self.x, self.y, c=self.color, padding=0.1)
        self.tap.source = scatter          # Link the stream to the updated plot 
        return scatter

explorer = MPGExplorer()

pn.Row(pn.Column(explorer.param, pn.panel(explorer.tap)), explorer.plot)