Skip to content

Commit

Permalink
Ensure vdims are initialized on PointDraw stream
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed May 24, 2018
1 parent 8711663 commit 0ad43ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions holoviews/plotting/bokeh/callbacks.py
Expand Up @@ -4,6 +4,7 @@
from bokeh.models import (CustomJS, FactorRange, DatetimeAxis, ColumnDataSource, Selection)

from ...core import OrderedDict
from ...core.util import dimension_sanitizer
from ...streams import (Stream, PointerXY, RangeXY, Selection1D, RangeX,
RangeY, PointerX, PointerY, BoundsX, BoundsY,
Tap, SingleTap, DoubleTap, MouseEnter, MouseLeave,
Expand Down Expand Up @@ -906,6 +907,12 @@ def initialize(self):
empty_value=self.streams[0].empty_value,
renderers=renderers)
self.plot.state.tools.append(point_tool)
source = self.plot.handles['source']
element = self.plot.current_frame
for d in element.dimensions():
dim = dimension_sanitizer(d.name)
if dim not in source.data:
source.data[dim] = element.dimension_values(d)
super(PointDrawCallback, self).initialize()


Expand Down
6 changes: 6 additions & 0 deletions tests/plotting/bokeh/testcallbacks.py
Expand Up @@ -143,6 +143,12 @@ def test_point_draw_callback_initialized_js(self):
self.assertEqual(plot.handles['source'].js_property_callbacks,
{'change:data': [plot.callbacks[0].callbacks[0]]})

def test_point_draw_callback_with_vdims_initialization(self):
points = Points([(0, 1, 'A')], vdims=['A'])
stream = PointDraw(source=points)
bokeh_server_renderer.get_plot(points)
self.assertEqual(stream.element.dimension_values('A'), np.array(['A']))

def test_point_draw_callback_with_vdims(self):
points = Points([(0, 1, 'A')], vdims=['A'])
point_draw = PointDraw(source=points)
Expand Down

0 comments on commit 0ad43ed

Please sign in to comment.