Reputation: 109
I am trying to add a hover tooltip to my bokeh plot. The tooltip shows up, but the area value I am trying to display shows up as '???'. I am using ColumnDataSource to set the plot source data, and area is a valid column in that data source. I can't figure out why the plot can't fine the area values.
source = ColumnDataSource(data=df.groupby('state').sum())
TOOLTIPS = [("area", "@%area")]
p = figure(x_range=source.data['state'], width=1300, height=1000)
p.vbar(x=source.data['state'], top=source.data['area'], width=.5)
from bokeh.models import HoverTool
p.add_tools(HoverTool(tooltips=TOOLTIPS))
Upvotes: 2
Views: 1966
Reputation: 109
The issue is Bokeh allows for two different ways of providing data to a glyph. But only one way works with a tooltip, if the tooltip references a column in the data. This line:
p.vbar(x=source.data['state'], top=source.data['area'], width=.5)
Should be changed to:
p.vbar(x='state', top='area', width=.5, source=source)
Upvotes: 6