Repository: bokeh/bokeh

Issue:
In a stacked bar chart there is no way to add tolltips for segments in column
If you have a stacked bar chart you would want to add different values in tooltips for each segment in a column. Currently there is no way of doing that as I'm aware: 

```
from bokeh.core.properties import value
from bokeh.io import show, output_file
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
from bokeh.models import HoverTool

fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
years = ["2015", "2016", "2017"]
colors = ["#c9d9d3", "#718dbf", "#e84d60"]

data = {'fruits' : fruits,
        '2015'   : [2, 1, 4, 3, 2, 4],
        '2016'   : [5, 3, 4, 2, 4, 6],
        '2017'   : [3, 2, 4, 4, 5, 3]}

source = ColumnDataSource(data=data)

p = figure(x_range=fruits, plot_height=250, title="Fruit Counts by Year",
           toolbar_location=None, tools="")

p.vbar_stack(years, x='fruits', width=0.9, color=colors, source=source,
             legend=[value(x) for x in years])


tooltips = HoverTool(
tooltips=[
    ("2015", "@2015"),
    ("2016", "@2016"),
    ("2017", "@2017"),
    ("index", "$index")
    ]
)

p.add_tools(tooltips)

show(p)
```
You can see that values from the column appear over all segments. 
Bokeh version 0.12.13  
Python version 3.6.3


Discussion:
So I think the most reasonable immediate solution at the core Bokeh level is simply to have `vbar_stack` return a list of the renderers it creates. Then separate hover tools could be made for each. That would be a little bit of work, but also higher level tools like Holoviews could use that facility to do this sort of thing automatically for users if then wanted. 

Resolving patch:
diff --git a/bokeh/plotting/figure.py b/bokeh/plotting/figure.py
--- a/bokeh/plotting/figure.py
+++ b/bokeh/plotting/figure.py
@@ -702,6 +702,9 @@ def hbar_stack(self, stackers, **kw):
         If a keyword value is a list or tuple, then each call will get one
         value from the sequence.
 
+        Returns:
+            list[GlyphRenderer]
+
         Examples:
 
             Assuming a ``ColumnDataSource`` named ``source`` with columns
@@ -720,8 +723,10 @@ def hbar_stack(self, stackers, **kw):
                 p.hbar(bottom=stack('2016'), top=stack('2016', '2017'), x=10, width=0.9, color='red', source=source)
 
         '''
+        result = []
         for kw in _stack(stackers, "left", "right", **kw):
-            self.hbar(**kw)
+            result.append(self.hbar(**kw))
+        return result
 
     def vbar_stack(self, stackers, **kw):
         ''' Generate multiple ``VBar`` renderers for levels stacked bottom
@@ -735,6 +740,9 @@ def vbar_stack(self, stackers, **kw):
         If a keyword value is a list or tuple, then each call will get one
         value from the sequence.
 
+        Returns:
+            list[GlyphRenderer]
+
         Examples:
 
             Assuming a ``ColumnDataSource`` named ``source`` with columns
@@ -754,8 +762,10 @@ def vbar_stack(self, stackers, **kw):
 
 
         '''
+        result = []
         for kw in _stack(stackers, "bottom", "top", **kw):
-            self.vbar(**kw)
+            result.append(self.vbar(**kw))
+        return result
 
     def graph(self, node_source, edge_source, layout_provider, **kwargs):
         ''' Creates a network graph using the given node, edge and layout provider.
diff --git a/examples/plotting/file/bar_stacked.py b/examples/plotting/file/bar_stacked.py
--- a/examples/plotting/file/bar_stacked.py
+++ b/examples/plotting/file/bar_stacked.py
@@ -1,6 +1,6 @@
 from bokeh.core.properties import value
 from bokeh.io import show, output_file
-from bokeh.models import ColumnDataSource
+from bokeh.models import ColumnDataSource, HoverTool
 from bokeh.plotting import figure
 
 output_file("bar_stacked.html")
@@ -19,8 +19,16 @@
 p = figure(x_range=fruits, plot_height=350, title="Fruit Counts by Year",
            toolbar_location=None, tools="")
 
-p.vbar_stack(years, x='fruits', width=0.9, color=colors, source=source,
-             legend=[value(x) for x in years])
+renderers = p.vbar_stack(years, x='fruits', width=0.9, color=colors, source=source,
+                         legend=[value(x) for x in years], name=years)
+
+for r in renderers:
+    year = r.name
+    hover = HoverTool(tooltips=[
+        ("%s total" % year, "@%s" % year),
+        ("index", "$index")
+    ], renderers=[r])
+    p.add_tools(hover)
 
 p.y_range.start = 0
 p.x_range.range_padding = 0.1
diff --git a/sphinx/source/docs/user_guide/examples/categorical_bar_stacked_hover.py b/sphinx/source/docs/user_guide/examples/categorical_bar_stacked_hover.py
new file mode 100644
--- /dev/null
+++ b/sphinx/source/docs/user_guide/examples/categorical_bar_stacked_hover.py
@@ -0,0 +1,41 @@
+from bokeh.core.properties import value
+from bokeh.io import show, output_file
+from bokeh.models import ColumnDataSource, HoverTool
+from bokeh.plotting import figure
+
+output_file("bar_stacked.html")
+
+fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
+years = ["2015", "2016", "2017"]
+colors = ["#c9d9d3", "#718dbf", "#e84d60"]
+
+data = {'fruits' : fruits,
+        '2015'   : [2, 1, 4, 3, 2, 4],
+        '2016'   : [5, 3, 4, 2, 4, 6],
+        '2017'   : [3, 2, 4, 4, 5, 3]}
+
+source = ColumnDataSource(data=data)
+
+p = figure(x_range=fruits, plot_height=350, title="Fruit Counts by Year",
+           toolbar_location=None, tools="")
+
+renderers = p.vbar_stack(years, x='fruits', width=0.9, color=colors, source=source,
+                         legend=[value(x) for x in years], name=years)
+
+for r in renderers:
+    year = r.name
+    hover = HoverTool(tooltips=[
+        ("%s total" % year, "@%s" % year),
+        ("index", "$index")
+    ], renderers=[r])
+    p.add_tools(hover)
+
+p.y_range.start = 0
+p.x_range.range_padding = 0.1
+p.xgrid.grid_line_color = None
+p.axis.minor_tick_line_color = None
+p.outline_line_color = None
+p.legend.location = "top_left"
+p.legend.orientation = "horizontal"
+
+show(p)


Test patch:
diff --git a/bokeh/plotting/tests/test_figure.py b/bokeh/plotting/tests/test_figure.py
--- a/bokeh/plotting/tests/test_figure.py
+++ b/bokeh/plotting/tests/test_figure.py
@@ -243,6 +243,42 @@ def test_render_level(self):
             p.circle([1, 2, 3], [1, 2, 3], level="bad_input")
 
 
+def test_hbar_stack_returns_renderers():
+    fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
+    years = ["2015", "2016", "2017"]
+    colors = ["#c9d9d3", "#718dbf", "#e84d60"]
+    data = {'fruits' : fruits,
+        '2015'   : [2, 1, 4, 3, 2, 4],
+        '2016'   : [5, 3, 4, 2, 4, 6],
+        '2017'   : [3, 2, 4, 4, 5, 3]}
+    source = ColumnDataSource(data=data)
+
+    p = plt.figure()
+    renderers = p.hbar_stack(years, y='fruits', height=0.9, color=colors, source=source,
+                         legend=[value(x) for x in years], name=years)
+    assert len(renderers) == 3
+    assert renderers[0].name == "2015"
+    assert renderers[1].name == "2016"
+    assert renderers[2].name == "2017"
+
+def test_vbar_stack_returns_renderers():
+    fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
+    years = ["2015", "2016", "2017"]
+    colors = ["#c9d9d3", "#718dbf", "#e84d60"]
+    data = {'fruits' : fruits,
+        '2015'   : [2, 1, 4, 3, 2, 4],
+        '2016'   : [5, 3, 4, 2, 4, 6],
+        '2017'   : [3, 2, 4, 4, 5, 3]}
+    source = ColumnDataSource(data=data)
+
+    p = plt.figure()
+    renderers = p.vbar_stack(years, x='fruits', width=0.9, color=colors, source=source,
+                         legend=[value(x) for x in years], name=years)
+    assert len(renderers) == 3
+    assert renderers[0].name == "2015"
+    assert renderers[1].name == "2016"
+    assert renderers[2].name == "2017"
+
 def test_title_kwarg_no_warning(recwarn):
     plt.figure(title="title")
     assert len(recwarn) == 0