In the code below, I would like to know what to put in place of "????" so that the guidance tool displays the name of the series (in this example, either "series 1" or "series 2")
from bokeh.plotting import figure, output_notebook, show
from bokeh.models import HoverTool, ColumnDataSource
output_notebook()
hover = HoverTool()
hover.tooltips=[("series name","????")]
f = figure(tools=[hover])
f.line([1,2,3],[2,1,5],legend="series 1")
f.line([1,2,3],[1,7,2],legend="series 2")
show(f)
I know that you can do the following to accomplish this work (see In Bokeh, how to add tooltips to a Timeseries chart (hover tool)? ). However, I embed graphics in an HTML file that will have many data points per plot and many graphics in the file, so I am interested in minimizing the size of the data source that is embedded in the HTML file.
from bokeh.plotting import figure, output_notebook, show
from bokeh.models import HoverTool, ColumnDataSource
output_notebook()
hover = HoverTool()
hover.tooltips=[("series name","@legend")]
f = figure(tools=[hover])
data1 = ColumnDataSource({"x":[1,2,3], "y":[2,1,5], "legend":["series 1"]*3})
data2 = ColumnDataSource({"x":[1,2,3], "y":[1,7,2], "legend":["series 2"]*3})
f.line("x","y",source=data1, legend="series 1")
f.line("x","y",source=data2, legend="series 2")
show(f)