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 vectorfield hover #6258

Merged
merged 8 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
16 changes: 14 additions & 2 deletions holoviews/plotting/bokeh/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,20 @@ def get_data(self, element, ranges, style):
elif cdim:
color = cdata.get(cdim.name)

data = {'x0': x0s, 'x1': x1s, 'y0': y0s, 'y1': y1s}
data = {
'x0': x0s,
'x1': x1s,
'y0': y0s,
'y1': y1s,
}
if 'hover' in self.handles:
data.update({
# tile to match the length of the segments
"x": np.tile(xs, 3),
"y": np.tile(ys, 3),
"Angle": np.tile(rads, 3),
"Magnitude": np.tile(lens, 3)
})
mapping = dict(x0='x0', x1='x1', y0='y0', y1='y1')
if cdim and color is not None:
data[cdim.name] = color
Expand All @@ -327,7 +340,6 @@ def get_data(self, element, ranges, style):
return (data, mapping, style)



class CurvePlot(ElementPlot):

padding = param.ClassSelector(default=(0, 0.1), class_=(int, float, tuple))
Expand Down
15 changes: 15 additions & 0 deletions holoviews/tests/plotting/bokeh/test_vectorfieldplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,18 @@ def test_vectorfield_color_index_color_clash(self):
"for 'line_color' option and declare a color_index; ignoring the color_index.\n"
)
self.assertEqual(log_msg, warning)

def test_vectorfield_no_hover_columns(self):
vectorfield = VectorField([(0, 0, 0), (0, 1, 1), (0, 2, 2)],
vdims='color').opts(tools=[])
plot = bokeh_renderer.get_plot(vectorfield)
keys = sorted(plot.handles["cds"].data)
assert keys == ["x0", "x1", "y0", "y1"]

def test_vectorfield_hover_columns(self):
vectorfield = VectorField([(0, 0, 0), (0, 1, 1), (0, 2, 2)],
vdims='color').opts(tools=["hover"])
plot = bokeh_renderer.get_plot(vectorfield)
keys = plot.handles["cds"].data.keys()
ahuang11 marked this conversation as resolved.
Show resolved Hide resolved
assert len(keys) == 8
ahuang11 marked this conversation as resolved.
Show resolved Hide resolved
assert keys == ["Angle", "Magnitude", "x", "x0", "x1", "y", "y0", "y1"]
Loading