I would like to include tooltips with my bar chart in either Bokeh or Holoviews. However, instead of getting the data showing the tooltip it is just giving me ???. I have tried both Bokeh and Holoviews and experience the same issue. I know this was issue that was discussed for awhile in both and wanted to know if any recent merges had fixed it and if so what is the best way to deal with it. Below is my code for Bokeh my code for holoviews is essentially the same.
p=Bar(df, 'Metrics', title="ED Metrics", values='Median', plot_width=900, plot_height=900, tooltips = [("Cases Recorded", "@Cases"), ("Cases Less Than Target", "@Less"), ("Median", "@Median")])
Bar
is part of the old, deprecated bokeh.charts
API that has since been completely removed from core Bokeh. It is still available as the bkcharts
package, but it is completely unmaintained and unsupported. It should not be used for any new work at this point.
However, recent work greatly improved the support for bar and other categorical plots using the stable, supported bokeh.plotting
API. There is large new User's Guide Section purely dedicated to explaining and demonstrating many kind of bar charts, both simple and sophisticated. Moreover, now that bar plots are easy to make using standard bokeh.plotting
calls, the general guidance and documentation for hover tools now applies as well.
You have not provided a complete minimal example including data to run, so I can't offer specific advice for your use case. Here is a complete example of a simple bar chart using pandas statistics (similar to what Bar
would do) with hover tool using the "cars" sample data and the bokeh.plotting
API:
from bokeh.io import show, output_file
from bokeh.models import HoverTool
from bokeh.plotting import figure
from bokeh.sampledata.autompg import autompg as df
output_file("groupby.html")
df.cyl = df.cyl.astype(str)
group = df.groupby('cyl')
p = figure(plot_height=350, x_range=group, toolbar_location=None, tools="")
p.vbar(x='cyl', top='mpg_mean', width=0.9, source=group)
p.add_tools(HoverTool(tooltips=[("Avg MPG", "@mpg_mean")]))
show(p)
Which produces the following result