Pass legend_label line property to hovertool as $name

Hello, I have a figure and a simple line in it and use Hovertools to read the line data

fig1 = bk_plotting.figure( width=700, height=450)

fig1.title.align = "center"
fig1.title.text_color = "black"
fig1.title.text_font_size = "25px"

# Define x-axis
fig1.xaxis.axis_label = "x"
fig1.xaxis.axis_label_text_font_size = "18px"
fig1.xaxis.axis_label_text_font = "Computer Modern"
fig1.xaxis.axis_label_text_font_style = 'normal'

# Define LHS y-axis
fig1.yaxis.axis_label = 'y'
fig1.yaxis.axis_line_color = "black"
fig1.yaxis.axis_label_text_font_size = "18px"
fig1.yaxis.axis_label_text_font = "Computer Modern"
fig1.yaxis.axis_label_text_font_style = 'normal'
fig1.y_range = Range1d(start=1, end=2)

    muted_color='gray', muted_alpha=0.2
   fig1.add_tools(HoverTool(show_arrow=True, line_policy='next', tooltips=[('name', '$name'), ('time', '$x{0.2f}'), ('Y', '$y')])))

Now I am interested in the “(‘name’, ‘$name’)” part of the Hovertool. I want to modify a lot of existing code so that the lines show their name while hovering and writing the property “name” for each line seems like a pain when the property “legend_label” is already defined. Is there any way to send the string inside “legend_label” to hovertool? I have tried using:

(‘name’, ‘$legend_label’)
(‘name’, ‘@legend_label’)
(‘name’, ‘@$legend_label’)
(‘name’, ‘@{legend_label}’)

without success

There’s only $name, so you will need to set the name property. (legend_label is not, in fact, a property of the glyph at all—it is a convenience parameter that causes a LegendItem to be created and added to the separate Legend object).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.