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

Support datashade points hover #1430

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add test
ahuang11 committed Oct 3, 2024
commit ea1d123abcde6e1e63f693672dbe3457cd646388
5 changes: 5 additions & 0 deletions hvplot/converter.py
Original file line number Diff line number Diff line change
@@ -1830,6 +1830,11 @@ def method_wrapper(ds, x, y):

# a workaround to show hover info for datashaded points
if self.hover and self.datashade and self.kind == 'points':
if self.hover_mode != 'mouse':
param.main.param.warning(
f'Got unsupported hover_mode={self.hover_mode!r} for '
f"datashaded points; reverting to 'mouse'."
)
inspector = inspect_points.instance(
streams=[PointerXY], transform=self._datashade_hover_transform
)
19 changes: 18 additions & 1 deletion hvplot/tests/testoperations.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
import pandas as pd
import pytest

from holoviews import Store, render
from holoviews import Store, render, renderer
from holoviews.element import Image, QuadMesh, Points
from holoviews.core.spaces import DynamicMap
from holoviews.core.overlay import Overlay
@@ -324,6 +324,23 @@ def test_downsample_resample_when(self, kind, eltype):
assert isinstance(element, eltype)
assert len(element) == 0

@parameterized.expand([(None,), (True,), ('vline',), ('hline',)])
Copy link
Member

Choose a reason for hiding this comment

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

Do you think there'd be a way to avoid calling get_plot? It's pretty expensive isn't it?

Copy link
Member

Choose a reason for hiding this comment

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

Many more tests will be needed to cover all the branches of the code introduced in the converter, these first two are a good start but they're very basic and just check whether the code doesn't error and the HoloViews type is the expected one.

def test_include_inspect_point_hover(self, hover):
df = pd.DataFrame(
np.random.multivariate_normal((0, 0), [[0.1, 0.1], [0.1, 1.0]], (5000,))
).rename({0: 'x', 1: 'y'}, axis=1)

p = df.hvplot.points(datashade=True, hover=hover)
assert renderer('bokeh').get_plot(p).name.startswith('Overlay')

def test_include_inspect_point_no_hover(self):
df = pd.DataFrame(
np.random.multivariate_normal((0, 0), [[0.1, 0.1], [0.1, 1.0]], (5000,))
).rename({0: 'x', 1: 'y'}, axis=1)

p = df.hvplot.points(datashade=True, hover=False)
assert renderer('bokeh').get_plot(p).name.startswith('RGB')


class TestChart2D(ComparisonTestCase):
def setUp(self):