Skip to content

Commit

Permalink
Fixed bug in bokeh ArrowPlot (#2172)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Dec 4, 2017
1 parent bc03827 commit 9b6a898
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions holoviews/plotting/bokeh/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
try:
from bokeh.models.arrow_heads import TeeHead, NormalHead
arrow_start = {'<->': NormalHead, '<|-|>': NormalHead}
arrow_end = {'->': NormalHead, '-[': TeeHead, '-|>': NormalHead, '-': None}
arrow_end = {'->': NormalHead, '-[': TeeHead, '-|>': NormalHead,
'-': None}
except:
from bokeh.models.arrow_heads import OpenHead, NormalHead
arrow_start = {'<->': NormalHead, '<|-|>': NormalHead}
arrow_end = {'->': NormalHead, '-[': OpenHead, '-|>': NormalHead, '-': None}
arrow_end = {'->': NormalHead, '-[': OpenHead, '-|>': NormalHead,
'-': None}

from ...element import HLine
from ...core.util import datetime_types
from .element import ElementPlot, CompositeElementPlot, text_properties, line_properties
from .element import (ElementPlot, CompositeElementPlot,
text_properties, line_properties)
from .util import date_to_integer


Expand All @@ -33,7 +36,8 @@ def get_data(self, element, ranges, style):
self._categorize_data(data, ('x', 'y'), element.dimensions())
data['text'] = [element.text]
style['text_align'] = element.halign
style['text_baseline'] = 'middle' if element.valign == 'center' else element.valign
baseline = 'middle' if element.valign == 'center' else element.valign
style['text_baseline'] = baseline
if 'color' in style:
style['text_color'] = style.pop('color')
return (data, mapping, style)
Expand Down Expand Up @@ -124,8 +128,6 @@ class ArrowPlot(CompositeElementPlot):

_style_groups = {'arrow': 'arrow', 'label': 'text'}

_plot_methods = dict(single='text')

def get_data(self, element, ranges, style):
plot = self.state
label_mapping = dict(x='x', y='y', text='text')
Expand Down Expand Up @@ -179,7 +181,8 @@ def _init_glyph(self, plot, mapping, properties, key):
else:
properties = {p if p == 'source' else 'text_'+p: v
for p, v in properties.items()}
glyph, _ = super(ArrowPlot, self)._init_glyph(plot, mapping, properties, 'text')
glyph, _ = super(ArrowPlot, self)._init_glyph(
plot, mapping, properties, 'text_1')
plot.renderers.append(glyph)
return None, glyph

Expand Down

0 comments on commit 9b6a898

Please sign in to comment.