I know you can add custom labels to plots using the Label() function, but you have to specify an (x,y) cordinate to put the label.
I have a few annotations for some timeseries data that I am adding to the plot using Span(), but what I'd really love is if I could add the labels to those Span annotations that would show up whenever you hover over the Span object. It seems like something that would be simple, but I'm really struggling.
Here is the sample code I've been working on to troubleshoot this:
p = figure(x_axis_type='datetime', y_axis_type='datetime', tools='hover')
p.line(daylight_warsaw_2013.Date,daylight_warsaw_2013.Sunset, line_dash='solid', line_width=2, legend="Sunset")
p.line(daylight_warsaw_2013.Date,daylight_warsaw_2013.Sunrise, line_dash='dotted', line_width=2, legend="Sunrise")
annotations = {
'start':{'timestamp':dt(2013, 3, 31,2,0,0),'desc':"start of daylight savings time"},
'end':{'timestamp':dt(2013, 10, 27, 3, 0, 0),'desc':"end of daylight savings time"}
}
def auto_annotate(df,plot):
for row in df.values():
xloc = time.mktime(row['timestamp'].timetuple())*1000
span = Span(location=xloc, dimension='height', line_width=2, line_dash='dashed',line_color='green')
label = Label(x=xloc, y=5000000, text=row['desc'])
plot.add_layout(label)
plot.add_layout(span)
auto_annotate(annotations,p)
show(p)
Keep in mind I have no idea how to use javascript.