I have a graph with multiple lines. I want to make a line in bold when hovered. Other lines should be untouched.
In the example below, the tooltip works fine, but the hover_glyph doesn't. If I hover one line then both lines are getting wider. If I hover the second line, nothing happens to both lines. How to make it working?
x = np.linspace(0, 4 * np.pi, 100)
y1 = np.sin(x)
y2 = np.cos(x)
output_notebook()
source = ColumnDataSource(pd.DataFrame(data={'L1': y1, 'L2': y2}, index=x))
f = figure(tools='xwheel_zoom, wheel_zoom, pan', active_scroll='xwheel_zoom', active_drag='pan')
g1 = f.line(x='index', y='L1', source=source, color=Spectral11[1], legend_label='L1', name='L1')
gg1 = g1.hover_glyph = Line(line_color=Spectral11[1], line_width=5)
g2 = f.line(x='index', y='L2', source=source, color=Spectral11[3], legend_label='L2', name='L2')
gg2 = g2.hover_glyph = Line(line_color=Spectral11[3], line_width=4)
hover = HoverTool(renderers=[g2])
hover.tooltips=[
('both fields', '@L1'+':'+'@L2'),
('name', '$y'),
('Number', '$name')
]
f.add_tools(hover)
hover2 = HoverTool(renderers=[g1])
hover2.tooltips=[
('name', '$y'),
('Number', '$name')
]
f.add_tools(hover2)
show(f)