Skip to content

Commit

Permalink
Small bugfixes for Polygon colormapping
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Apr 7, 2017
1 parent 4bf8485 commit 7155cdc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions holoviews/plotting/bokeh/path.py
Expand Up @@ -87,9 +87,10 @@ def get_data(self, element, ranges=None, empty=False):

if element.vdims and element.level is not None:
cdim = element.vdims[0]
dim_name = util.dimension_sanitizer(cdim.name)
cmapper = self._get_colormapper(cdim, element, ranges, style)
data[cdim.name] = [] if empty else element.dimension_values(2)
mapping['fill_color'] = {'field': cdim.name,
data[dim_name] = [] if empty else [element.level for _ in range(len(xs))]
mapping['fill_color'] = {'field': dim_name,
'transform': cmapper}

if any(isinstance(t, HoverTool) for t in self.state.tools):
Expand Down
12 changes: 12 additions & 0 deletions tests/testplotinstantiation.py
Expand Up @@ -545,6 +545,18 @@ def test_polygons_colored_batched(self):
source = plot.handles['source']
self.assertEqual(source.data['Value'], list(range(5)))

def test_polygons_colored_batched_unsanitized(self):
polygons = NdOverlay({j: Polygons([[(i**j, i) for i in range(10)] for i in range(2)],
level=j, vdims=['some ? unescaped name'])
for j in range(5)})(plot=dict(legend_limit=0))
plot = list(bokeh_renderer.get_plot(polygons).subplots.values())[0]
cmapper = plot.handles['color_mapper']
self.assertEqual(cmapper.low, 0)
self.assertEqual(cmapper.high, 4)
source = plot.handles['source']
self.assertEqual(source.data['some_question_mark_unescaped_name'],
[j for i in range(5) for j in [i, i]])

def test_points_colormapping(self):
points = Points(np.random.rand(10, 4), vdims=['a', 'b'])(plot=dict(color_index=3))
self._test_colormapping(points, 3)
Expand Down

0 comments on commit 7155cdc

Please sign in to comment.