I am using Holoviews to display a Sankey Diagram and would like to customize the information displayed when positioning a cursor over the diagram. However, I don't know how to display the correct labels.
Taking the 2nd example from the docs, I can add a custom HoverTool
import holoviews as hv
from holoviews import opts
from bokeh.models import HoverTool
nodes = ["PhD", "Career Outside Science", "Early Career Researcher", "Research Staff",
"Permanent Research Staff", "Professor", "Non-Academic Research"]
nodes = hv.Dataset(enumerate(nodes), 'index', 'label')
edges = [
(0, 1, 53), (0, 2, 47), (2, 6, 17), (2, 3, 30), (3, 1, 22.5), (3, 4, 3.5), (3, 6, 4.), (4, 5, 0.45)
]
value_dim = hv.Dimension('Percentage', unit='%')
careers = hv.Sankey((edges, nodes), ['From', 'To'], vdims=value_dim)
# this is my custom HoverTool
hover = HoverTool(
tooltips = [
("From": "@From"), # this displays the index: "0", "1" etc.
("To": "@To"), # How to display the label ("PhD", "Career Outside Science", ...)?
]
)
careers.opts(
opts.Sankey(labels='label', tools=[hover]))
Same as in the example shown in the docs, the HoverTool
displays the index values for "From" and "To" (e.g. "0", "1") etc., which do not necessarily mean anything to the user.
Is there a way to display the associated label (e.g. "PhD", "Career Outside Science", ...) in the HooverTool
syntax?
I am using Holoviews 1.11.2 and Bokeh 1.0.4.