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

Display hover info for all dimensions on Spikes #854

Merged
merged 2 commits into from
Sep 8, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion holoviews/element/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class Spikes(Chart):

group = param.String(default='Spikes', constant=True)

kdims = param.List(default=[Dimension('x')])
kdims = param.List(default=[Dimension('x')], bounds=(1, 1))

vdims = param.List(default=[])

Expand Down
26 changes: 12 additions & 14 deletions holoviews/plotting/bokeh/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from bokeh.models import Circle, GlyphRenderer, ColumnDataSource, Range1d

from ...element import Raster, Points, Polygons, Spikes
from ...core.util import max_range, basestring
from ...core.util import max_range, basestring, dimension_sanitizer
from ...core.options import abbreviated_exception
from ..util import compute_sizes, get_sideplot_ranges, match_spec, map_colors
from .element import ElementPlot, line_properties, fill_properties
Expand Down Expand Up @@ -336,29 +336,24 @@ def get_extents(self, element, ranges):
b, t = self.position, self.position+self.spike_length
return l, b, r, t


def get_data(self, element, ranges=None, empty=False):
style = self.style[self.cyclic_index]
dims = element.dimensions(label=True)

pos = self.position
mapping = dict(xs='xs', ys='ys')
if empty:
xs, ys, keys = [], [], []
mapping = dict(xs=dims[0], ys=dims[1] if len(dims) > 1 else 'heights')
xs, ys = [], []
elif len(dims) > 1:
xs, ys = zip(*(((x, x), (pos, pos+y))
for x, y in element.array()))
mapping = dict(xs=dims[0], ys=dims[1])
keys = (dims[0], dims[1])
xs, ys = zip(*(((x, x), (pos+y, pos))
for x, y in element.array(dims[:2])))
else:
height = self.spike_length
xs, ys = zip(*(((x[0], x[0]), (pos, pos+height))
for x in element.array()))
mapping = dict(xs=dims[0], ys='heights')
keys = (dims[0], 'heights')
xs, ys = zip(*(((x[0], x[0]), (pos+height, pos))
for x in element.array(dims[:1])))

if not empty and self.invert_axes: keys = keys[::-1]
data = dict(zip(keys, (xs, ys)))
data = dict(zip(('xs', 'ys'), (xs, ys)))

cmap = style.get('palette', style.get('cmap', None))
cdim = element.get_dimension(self.color_index)
Expand All @@ -374,8 +369,11 @@ def get_data(self, element, ranges=None, empty=False):
colors = map_colors(cvals, crange, cmap)
data[map_key] = colors

return data, mapping
if 'hover' in self.tools+self.default_tools and not empty:
for d in dims:
data[dimension_sanitizer(d)] = element.dimension_values(d)

return data, mapping


class SideSpikesPlot(SpikesPlot):
Expand Down