-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
Cannot link tap to float slider #6384
Labels
type: enhancement
Minor feature or improvement to an existing feature
Comments
ahuang11
added
TRIAGE
Needs triaging
type: enhancement
Minor feature or improvement to an existing feature
and removed
TRIAGE
Needs triaging
labels
Sep 23, 2024
This issue has been mentioned on HoloViz Discourse. There might be relevant details there: |
Fully in favor. |
Not sure how to link the params: import param
import holoviews as hv
import panel as pn
pn.extension()
class Test(pn.custom.PyComponent):
x = param.Number(default=1, allow_refs=True)
y = param.Number(default=0.5, allow_refs=True)
def __init__(self, **params):
super().__init__(**params)
self._tap = hv.streams.Tap.from_param(x=self.param.x, y=self.param.y)
hv_pane = pn.pane.HoloViews(object=hv.DynamicMap(self.plot, streams=[self._tap]))
self._layout = pn.Column(hv_pane, self.param.x, self.param.y)
def plot(self, x, y):
return hv.Points([(x, y)]).opts(tools=['tap'], xlim=(0, 2), ylim=(0, 2))
def __panel__(self):
return self._layout
test = Test()
test Under the hood changes: class Tap(PointerXY):
"""
The x/y-position of a tap or click in data coordinates.
"""
x = param.ClassSelector(class_=pointer_types, default=None,
constant=False, allow_refs=True, doc="""
Pointer position along the x-axis in data coordinates""")
y = param.ClassSelector(class_=pointer_types, default=None,
constant=False, allow_refs=True, doc="""
Pointer position along the y-axis in data coordinates""")
@classmethod
def from_param(cls, x=None, y=None):
tap = cls(x=x, y=y)
tap._x_parameterized = x.owner if isinstance(x, param.Parameter) else None
tap._y_parameterized = y.owner if isinstance(y, param.Parameter) else None
tap.param.watch(tap._event, ["x", "y"])
return tap
def _event(self, *events):
print(self.x, self.y)
self._x_parameterized.x = self.param.x
self._y_parameterized.y = self.param.y
self.trigger([self]) It works fine, until tapping... then it unsyncs the widget when tapped. Screen.Recording.2024-10-09.at.2.49.04.PM.mov |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For widgets, there’s pn.Param and from_param.
What’s the equivalent for HoloViews streams?
https://discourse.holoviz.org/t/whats-the-best-practice-for-linking-up-holoviews-streams-with-parameterized/8215/3
I thought the following would work, but I get
TypeError: Constant parameter 'x' cannot be modified
Can we remove the
constant=True
, or create a dedicated method likefrom_param
orfrom_params
?The workaround is a bit more code
The text was updated successfully, but these errors were encountered: