I'm trying to create custom hover based on data on a stacked chart. In the example below, if user hovers over 'cat1', then 'cat1_text' should be returned; 'cat2_text' and 'cat3_text' for 'cat2' and 'cat3' accordingly.
For the tooltip, since $name will return either 'cat1','cat2', or 'cat3', I thought by adding '_text', the value will be called accordingly (but of course this seems not to be the way python/bokeh works). I was thinking about using any function/index calls as well, but not too sure how to do so. Kindly advice. Many thanks!
category = ['cat1', 'cat2', 'cat3']
data = {'timeVal' : [0,1,2,3,4,5],
'cat1' : [2, 1, 4, 3, 2, 4],
'cat2' : [5, 3, 4, 2, 4, 6],
'cat3' : [3, 2, 4, 4, 5, 3],
'cat1_text' : ['a','b','c','d','e','f'],
'cat2_text' : ['a1','b1','c1','d1','e1','f1'],
'cat3_text' : ['a2','b2','c2','d2','e2','f2'],
}
toolTipArr = [
("name", "$name"),
("count", "@$name"),
("info", '@'+'$name'+'_text}')
]
p = figure(x_range=(startTime,endTime), plot_height=250, plot_width=1000, title="project",
toolbar_location="right", tools="hover,pan,wheel_zoom,box_zoom,reset",
tooltips=toolTipArr)
p.vbar_stack(category, x='timeVal', width=2, color=colors, source=data,
legend=[value(x) for x in category])