Search code examples
plotchartshovertooltipbokeh

Bokeh Charts: Custom HoverTool variables for Bar Charts


If I make a bar chart like this:

  bar = Bar(data,labels,tools='Hover')

I can make tooltips like this:

  hover = bar.select(dict(type=HoverTool))

  hover.tooltips = [
      ('Grade',' $x'),
      ('Students',' @Students'),
    ]

However, when I do variables with '@variable' in the tooltips, I am limited to those specified in data. In normal Bokeh plots, I can have custom variables associated with data points by using a ColumnDataSource. Bar does not support ColumnDataSources. Is there another way to make custom variables available in Bokeh chart tooltips (hover)?


Solution

  • There's is an open PR to add this feature to the charts interface.
    It's going to be part of the next bokeh release and also be available through the dev builds (or in the master branch of course) as soon as it gets merged if you need it sooner.