Skip to content

Commit

Permalink
Merge pull request #1007 from ioam/bokeh_bar_no_legend
Browse files Browse the repository at this point in the history
Correctly suppress Bars legend in bokeh>0.12.2
  • Loading branch information
jlstevens committed Dec 10, 2016
2 parents ceaa6d4 + b7ef2ab commit bc9fe71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion holoviews/plotting/bokeh/chart.py
Expand Up @@ -591,5 +591,8 @@ def _init_chart(self, element, ranges):
plot = Bar(element.dframe(), values=vdim,
continuous_range=crange, **kwargs)
if not self.show_legend:
plot.legend[0].legends[:] = []
if bokeh_version > '0.12.2':
plot.legend[0].items[:] = []
else:
plot.legend[0].legends[:] = []
return plot
9 changes: 8 additions & 1 deletion tests/testplotinstantiation.py
Expand Up @@ -11,7 +11,7 @@
NdOverlay, GridSpace)
from holoviews.element import (Curve, Scatter, Image, VLine, Points,
HeatMap, QuadMesh, Spikes, ErrorBars,
Scatter3D, Path, Polygons)
Scatter3D, Path, Polygons, Bars)
from holoviews.element.comparison import ComparisonTestCase
from holoviews.streams import PositionXY, PositionX
from holoviews.plotting import comms
Expand Down Expand Up @@ -228,6 +228,13 @@ def history_callback(x, history=deque(maxlen=10)):
self.assertEqual(data['x'], np.arange(10))
self.assertEqual(data['y'], np.arange(10, 20))

def test_bars_suppress_legend(self):
bars = Bars([('A', 1), ('B', 2)])(plot=dict(show_legend=False))
plot = bokeh_renderer.get_plot(bars)
plot.initialize_plot()
fig = plot.state
assert len(fig.legend[0].items) == 0


class TestPlotlyPlotInstantiation(ComparisonTestCase):

Expand Down

0 comments on commit bc9fe71

Please sign in to comment.