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

Add popup position and anchor #6414

Merged
merged 21 commits into from
Oct 23, 2024
Merged

Add popup position and anchor #6414

merged 21 commits into from
Oct 23, 2024

Conversation

ahuang11
Copy link
Collaborator

@ahuang11 ahuang11 commented Oct 16, 2024

Closes #6266

image
import numpy as np
import holoviews as hv

hv.extension("bokeh")


def popup_stats(index):
    if not index:
        return
    return points.iloc[index].dframe().describe()


points = hv.Points(np.random.randn(1000, 2))

hv.streams.Selection1D(
    source=points,
    popup=popup_stats,
    popup_position="right"
)

points.opts(
    tools=["xbox_select"],
    active_tools=["xbox_select"],
    size=6,
    color="black",
    fill_color=None,
    width=500,
    height=500
)
import numpy as np
import holoviews as hv

hv.extension("bokeh")


def popup_stats(index):
    if not index:
        return
    return points.iloc[index].dframe().describe()


points = hv.Points(np.random.randn(1000, 2))

hv.streams.BoundsXY(source=points, popup="Used Box Select", popup_position="top_right")
hv.streams.Lasso(source=points, popup="Used Lasso Select", popup_position="bottom_right")
hv.streams.Tap(source=points, popup="Used Tap")

points.opts(
    tools=["box_select", "lasso_select", "tap"],
    active_tools=["lasso_select"],
    size=6,
    color="black",
    fill_color=None,
    width=500,
    height=500
)
image

@ahuang11 ahuang11 force-pushed the popup_position_anchor branch from 441d3db to f4cabe6 Compare October 16, 2024 23:25
@ahuang11 ahuang11 requested review from philippjfr and hoxbro October 16, 2024 23:35
@ahuang11 ahuang11 added the type: enhancement Minor feature or improvement to an existing feature label Oct 16, 2024
Copy link

codecov bot commented Oct 17, 2024

Codecov Report

Attention: Patch coverage is 74.45652% with 47 lines in your changes missing coverage. Please review.

Project coverage is 88.51%. Comparing base (2e4979b) to head (ab04349).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
holoviews/tests/ui/bokeh/test_callback.py 74.28% 45 Missing ⚠️
holoviews/plotting/bokeh/callbacks.py 66.66% 1 Missing ⚠️
holoviews/streams.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6414      +/-   ##
==========================================
+ Coverage   88.50%   88.51%   +0.01%     
==========================================
  Files         323      323              
  Lines       68620    68599      -21     
==========================================
- Hits        60730    60722       -8     
+ Misses       7890     7877      -13     

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

Copy link
Member

@hoxbro hoxbro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate that there is so much "almost" repeatable code, but I can't think of a better way to do it.

Because most of the logic is inside CustomJS, I'm leaning toward testing every position/geometry type case. Hopefully, this can be done with parameterized unit tests.

Also the test_stream_popup_polygons_selection1d fails which is somewhat

holoviews/streams.py Outdated Show resolved Hide resolved
holoviews/plotting/bokeh/callbacks.py Outdated Show resolved Hide resolved
holoviews/plotting/bokeh/callbacks.py Outdated Show resolved Hide resolved
holoviews/plotting/bokeh/callbacks.py Outdated Show resolved Hide resolved
ahuang11 and others added 2 commits October 21, 2024 11:32
Commit suggestions

Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>
@ahuang11
Copy link
Collaborator Author

Okay I think I addressed your review comments; let me know if there's anything else.

@ahuang11 ahuang11 requested a review from hoxbro October 21, 2024 22:20
Copy link
Member

@hoxbro hoxbro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could benefit from having a class with some helper functions for the popup tests. There seems to be a lot of repeating code, which makes it somewhat hard to read.

The helper functions should have long descriptive names so we don't need to look into the functions to understand what happens and don't need to write comments.

holoviews/tests/ui/bokeh/test_callback.py Outdated Show resolved Hide resolved
holoviews/tests/ui/bokeh/test_callback.py Show resolved Hide resolved
holoviews/tests/ui/bokeh/test_callback.py Outdated Show resolved Hide resolved
holoviews/tests/ui/bokeh/test_callback.py Outdated Show resolved Hide resolved
holoviews/tests/ui/bokeh/test_callback.py Outdated Show resolved Hide resolved
holoviews/plotting/bokeh/callbacks.py Outdated Show resolved Hide resolved
ahuang11 and others added 3 commits October 22, 2024 07:46
Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>
@ahuang11
Copy link
Collaborator Author

Okay it's now all tidy~

@ahuang11 ahuang11 requested a review from hoxbro October 22, 2024 15:39
@hoxbro
Copy link
Member

hoxbro commented Oct 22, 2024

Looks much better!

However, one test is failing. Can you take a look at it before I review it?

@ahuang11
Copy link
Collaborator Author

It was passing locally :| but anyways fixed

@hoxbro hoxbro enabled auto-merge (squash) October 23, 2024 07:05
@hoxbro hoxbro merged commit d753397 into main Oct 23, 2024
14 checks passed
@hoxbro hoxbro deleted the popup_position_anchor branch October 23, 2024 07:53
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.

Bounds stream popup placement incorrect when BoxSelectTool uses dimensions="width"
2 participants