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

Fix popup positioning on polygons #6411

Merged
merged 5 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions holoviews/plotting/bokeh/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,13 +1191,24 @@ def _watch_position(self):
}
if (!xs || !ys) { return }
for (const i of indices) {
const tx = xs[i]
let ix = xs[i]
let iy = ys[i]
if (typeof ix === 'number') {
ix = [ix]
iy = [iy]
} else {
while (ix.length && (typeof ix[0] !== 'number')) {
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
ix = ix[0]
iy = iy[0]
}
}
const tx = Math.max(...ix)
if (!x || (tx > x)) {
x = xs[i]
x = tx
}
const ty = ys[i]
const ty = Math.max(...iy)
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
if (!y || (ty > y)) {
y = ys[i]
y = ty
}
}
if (x && y) {
Expand Down
18 changes: 18 additions & 0 deletions holoviews/tests/ui/bokeh/test_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,24 @@ def popup_form(name):
expect(locator).to_have_count(1)


@skip_popup
@pytest.mark.usefixtures("bokeh_backend")
def test_stream_popup_polygons(serve_hv):
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
def popup_form(name):
return f"# {name}"

points = hv.Polygons([np.random.randn(10, 2)]).opts(tools=["tap"])
hv.streams.Tap(source=points, popup=popup_form("Tap"))

page = serve_hv(points)
hv_plot = page.locator('.bk-events')
hv_plot.click()
expect(hv_plot).to_have_count(1)

locator = page.locator("#tap")
expect(locator).to_have_count(1)


@skip_popup
@pytest.mark.usefixtures("bokeh_backend")
def test_stream_popup_none(serve_hv, points):
Expand Down