Skip to content

Commit

Permalink
Apply Labels offset using bokeh transform
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Feb 5, 2019
1 parent cf2fc33 commit bc419bb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions holoviews/plotting/bokeh/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
arrow_start = {'<->': NormalHead, '<|-|>': NormalHead}
arrow_end = {'->': NormalHead, '-[': OpenHead, '-|>': NormalHead,
'-': None}
from bokeh.transform import dodge

from ...core.util import datetime_types, dimension_sanitizer, basestring
from ...element import HLine
Expand Down Expand Up @@ -100,12 +101,15 @@ def get_data(self, element, ranges, style):
dims = element.dimensions()
coords = (1, 0) if self.invert_axes else (0, 1)
xdim, ydim, tdim = (dimension_sanitizer(dims[i].name) for i in coords+(2,))
if self.invert_axes:
xdim, ydim = ydim, xdim
mapping = dict(x=xdim, y=ydim, text=tdim)
data = {d: element.dimension_values(d) for d in (xdim, ydim)}
if self.xoffset is not None:
data[xdim] = data[xdim] + self.xoffset
mapping['x'] = dodge(xdim, self.xoffset)
if self.yoffset is not None:
data[ydim] = data[ydim] + self.yoffset
mapping['y'] = dodge(ydim, self.yoffset)
print(mapping, data.keys(), self.xoffset, self.yoffset)
data[tdim] = [dims[2].pprint_value(v) for v in element.dimension_values(2)]
self._categorize_data(data, (xdim, ydim), element.dimensions())

Expand Down

0 comments on commit bc419bb

Please sign in to comment.