Skip to content

Commit

Permalink
Merge af88951 into f3af5c8
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed May 5, 2017
2 parents f3af5c8 + af88951 commit f2161ac
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions holoviews/plotting/bokeh/chart.py
Expand Up @@ -10,6 +10,7 @@
Range1d, CustomJS, HoverTool)
from bokeh.models.tools import BoxSelectTool

from ...core.dimension import Dimension
from ...core.util import max_range, basestring, dimension_sanitizer
from ...core.options import abbreviated_exception
from ...core.spaces import DynamicMap
Expand Down Expand Up @@ -602,7 +603,11 @@ def initialize_plot(self, ranges=None, plot=None, plots=None, source=None):
self.handles['plot'] = plot
self.handles['glyph_renderers'] = [r for r in plot.renderers
if isinstance(r, GlyphRenderer)]
self._update_chart(key, element, ranges)
if self.dynamic and not self.static:
self._update_chart(key, element, ranges)
else:
properties = self._plot_properties(key, plot, element)
plot.update(**properties)

# Update plot, source and glyph
self.drawn = True
Expand Down Expand Up @@ -694,11 +699,11 @@ class BarPlot(ChartPlot):
mapped onto separate groups, categories and stacks.
"""

group_index = param.Integer(default=0, doc="""
group_index = param.Integer(default=None, doc="""
Index of the dimension in the supplied Bars
Element, which will be laid out into groups.""")

stack_index = param.Integer(default=2, doc="""
stack_index = param.Integer(default=None, doc="""
Index of the dimension in the supplied Bars
Element, which will stacked.""")

Expand All @@ -709,11 +714,21 @@ def _init_chart(self, element, ranges):
vdim = element.dimensions('value', True)[0]

kwargs = self.style[self.cyclic_index]
if self.group_index < element.ndims:
kwargs['label'] = kdims[self.group_index]
if self.stack_index < element.ndims:
kwargs['label'] = kdims[0]
if self.stack_index and self.stack_index < element.ndims:
kwargs['stack'] = kdims[self.stack_index]
elif self.group_index and self.group_index < element.ndims:
kwargs['group'] = kdims[self.group_index]
crange = Range1d(*ranges.get(vdim))

tooltips = None
if any(t == 'hover' or isinstance(t, HoverTool)
for t in self.tools+self.default_tools):
tooltips, hover_opts = self._hover_opts(element)
tooltips = [(ttp.pprint_label, '@{%s}' % dimension_sanitizer(ttp.name))
if isinstance(ttp, Dimension) else ttp for ttp in tooltips]
tooltips[-1] = (tooltips[-1][0], '@{height}')

plot = Bar(element.dframe(), values=vdim,
continuous_range=crange, **kwargs)
continuous_range=crange, tooltips=tooltips, **kwargs)
return plot

0 comments on commit f2161ac

Please sign in to comment.