Skip to content

Commit

Permalink
Added styles for PointDraw (#3819) (#4063)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamrajeevpunekar authored and philippjfr committed Oct 30, 2019
1 parent f6afa0c commit ae8619a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion holoviews/plotting/bokeh/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,14 +976,17 @@ def _create_style_callback(self, cds, glyph, length_var):
cds.js_on_change('data', cb)


class PointDrawCallback(CDSCallback):
class PointDrawCallback(GlyphDrawCallback):

def initialize(self, plot_id=None):
plot = self.plot
stream = self.streams[0]
renderers = [self.plot.handles['glyph_renderer']]
kwargs = {}
if stream.num_objects:
kwargs['num_objects'] = stream.num_objects
if stream.styles:
self._create_style_callback(plot.handles['cds'], plot.handles['glyph'], 'x')
point_tool = PointDrawTool(drag=all(s.drag for s in self.streams),
empty_value=stream.empty_value,
renderers=renderers, **kwargs)
Expand Down
7 changes: 6 additions & 1 deletion holoviews/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,12 +1069,17 @@ class PointDraw(CDSStream):
num_objects: int
The number of polygons that can be drawn before overwriting
the oldest polygon.
styles: dict
A dictionary specifying lists of styles to cycle over whenever
a new Point glyph is drawn.
"""

def __init__(self, empty_value=None, drag=True, num_objects=0, **params):
def __init__(self, empty_value=None, drag=True, num_objects=0, styles={}, **params):
self.drag = drag
self.empty_value = empty_value
self.num_objects = num_objects
self.styles = styles
super(PointDraw, self).__init__(**params)

@property
Expand Down

0 comments on commit ae8619a

Please sign in to comment.