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

Added styles for PointDraw (#3819) #4063

Merged
merged 2 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation here seems off.

"""

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