Reputation: 435
I want to make a bar chart of some simple data, e.g. a pandas dataframe like this.
Cats 4
Dogs 3
Mice 27
I would like a tooltip which displays something like this when hovering over a bar:
Name: Cats
Count: 4
With a bar chart, this worked with
hover.tooltips = [
('Name', ' $x'),
('Count', ' @height'),
]
I since switched to vbars. What would be the corresponding keyword for @height? Or does it generally not work this way with vbars/hbars?
Upvotes: 3
Views: 942
Reputation: 435
I figured it out. I could make an extra ColumnDataSource like this:
hover_help = ColumnDataSource(dict(
count=[value for value in animals["No"]]
))
which yields a list of values for animals. This can then be used for the vbar like this:
p.vbar(source=hover_help, bottom=0, x=animal_names, top=animals['No'], color='#18286b', legend=False, **bar_opts)
Even if the source is not used as a data source, it can now be used for the tooltip:
hover.tooltips = [
('Name', ' $x'),
('Count', ' @count'),
]
Upvotes: 2