Skip to content

Commit

Permalink
Merge pull request #537 from ioam/bokeh_span
Browse files Browse the repository at this point in the history
Switched Bokeh LineAnnotationPlot to use Span annotation
  • Loading branch information
jbednar authored Sep 23, 2016
2 parents d457c32 + 7f6db14 commit 01c66c6
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions holoviews/plotting/bokeh/annotation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import defaultdict

import numpy as np
from bokeh.models import BoxAnnotation
from bokeh.models import Span

from ...element import HLine, VLine
from .element import ElementPlot, text_properties, line_properties
Expand Down Expand Up @@ -46,29 +46,20 @@ class LineAnnotationPlot(ElementPlot):

def get_data(self, element, ranges=None, empty=False):
data, mapping = {}, {}
if (isinstance(element, HLine) or
(isinstance(element, VLine) and self.invert_axes)):
mapping['bottom'] = element.data
mapping['top'] = element.data
elif (isinstance(element, VLine) or
(isinstance(element, HLine) and self.invert_axes)):
mapping['left'] = element.data
mapping['right'] = element.data
mapping['dimension'] = 'width' if isinstance(element, HLine) else 'height'
mapping['location'] = element.data
return (data, mapping)


def _init_glyph(self, plot, mapping, properties):
"""
Returns a Bokeh glyph object.
"""
properties.pop('source', None)
properties.pop('legend', None)
box = BoxAnnotation(plot=plot, level='overlay',
**dict(mapping, **properties))
properties.pop('source')
properties.pop('legend')
box = Span(level='overlay', **dict(mapping, **properties))
plot.renderers.append(box)
return None, box


def get_extents(self, element, ranges=None):
return None, None, None, None

Expand Down

0 comments on commit 01c66c6

Please sign in to comment.