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

feat: Implement stream.from_param #6396

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

feat: Implement stream.from_param #6396

wants to merge 3 commits into from

Conversation

ahuang11
Copy link
Collaborator

@ahuang11 ahuang11 commented Sep 27, 2024

Closes #6384

Wondering how to bidirectionally link it.

Currently, the widgets can update the point location, but tapping does not update the widgets

Screen.Recording.2024-09-27.at.2.36.22.PM.mov
import param
import holoviews as hv
import panel as pn

pn.extension()

class TapTest(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

tap_test = TapTest()
tap_test.show()

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.49%. Comparing base (017361b) to head (7a75695).
Report is 47 commits behind head on main.

Files with missing lines Patch % Lines
holoviews/streams.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #6396    +/-   ##
========================================
  Coverage   88.48%   88.49%            
========================================
  Files         323      323            
  Lines       68459    68673   +214     
========================================
+ Hits        60579    60769   +190     
- Misses       7880     7904    +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ahuang11 ahuang11 added the type: enhancement Minor feature or improvement to an existing feature label Oct 5, 2024
@ahuang11 ahuang11 closed this Oct 22, 2024
@ahuang11 ahuang11 reopened this Oct 28, 2024
@ahuang11 ahuang11 changed the title Implement stream.from_param feat: Implement stream.from_param Dec 3, 2024
@ahuang11
Copy link
Collaborator Author

ahuang11 commented Dec 4, 2024

@philippjfr

TapStream works bidirectionally, however, Range* streams seem to only work with adjusting the zoom on the plot, and not manually adjusting the widget, i.e. when I change the widget value, the plot's xlim doesn't update.
image

import param
import holoviews as hv
import panel as pn

pn.extension()

class StreamTest(pn.custom.PyComponent):

    x_range = param.Range(default=(0, 10))

    def __init__(self, **params):
        super().__init__(**params)

        self._rangexy = hv.streams.RangeX.from_param(x_range=(self.param.x_range))
        hv_pane = pn.pane.HoloViews(object=hv.DynamicMap(self.plot, streams=[self._rangexy]).apply.opts(xlim=self.param.x_range))
        self._layout = pn.Column(hv_pane, self.param.x_range)

    def plot(self, x_range):
        return hv.Points([0, 0])

    def __panel__(self):
        return self._layout

tap_test = StreamTest()
tap_test.show()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Minor feature or improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot link tap to float slider
2 participants