Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Parameters work with DynamicMap just as bound functions. #6161

Open
MarcSkovMadsen opened this issue Mar 22, 2024 · 1 comment
Open
Labels
TRIAGE Needs triaging

Comments

@MarcSkovMadsen
Copy link
Collaborator

Motivated by holoviz/panel#6543 where Philipp states this should absolute be supported.

I.e. pn.pane.HoloViews(hv.DynamicMap(watch_view.param.plot)) in the below should work just as if plot was a bound function.

import panel as pn
import param
import pandas as pd
import numpy as np
import hvplot.pandas
import holoviews as hv

pn.extension("plotly")


class Data(param.Parameterized):
    value = param.DataFrame()

    submit = param.Event()

    @pn.depends("submit", watch=True, on_init=True)
    def _update_value(self):
        x = np.random.rand(10)
        y = np.random.rand(10)
        self.value = pd.DataFrame({"x": x, "y": y})


class WatchStorage(param.Parameterized):
    data = param.ClassSelector(class_=Data, allow_refs=True)

    plot = param.Parameter()

    @pn.depends("data.value", watch=True, on_init=True)
    def _update_plot(self):
        self.plot = self.data.value.hvplot(x='x', y='y', title='Scatter Plot')


data = Data()

watch_view = WatchStorage(data=data)


pn.Column(
    pn.Row(
        pn.pane.HoloViews(hv.DynamicMap(watch_view.param.plot))
    ),
).servable()

Currently it does not work

image

@MarcSkovMadsen MarcSkovMadsen added the TRIAGE Needs triaging label Mar 22, 2024
@philippjfr
Copy link
Member

Note this isn't about parameters specifically but all valid references including reactive expressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TRIAGE Needs triaging
Projects
None yet
Development

No branches or pull requests

2 participants