
I’m trying to define an event in the bojeh server that through a callback function allows you to locate in a glyph the value $index that I read in the tooltip with a tap or double tap. I attach an example.
from bokeh.io import curdoc,show
from bokeh.models import ColumnDataSource
from bokeh.plotting import Figure
from bokeh.layouts import row
from bokeh.events import Tap
from bokeh.events import DoubleTap
from bokeh.models import TapTool
from functools import partial
def callbackTapGantt(sorgente,nomeColonna,figura):
print(sorgente)
print(nomeColonna)
print(sorgente.data[nomeColonna])
selected = sorgente.selected.indices
print(“selected=”,sorgente.selected)
print(“selected=”,sorgente.selected.indices)
print(“the $index value ???”)
return
CDS = ColumnDataSource(
data = dict(Color = [‘green’,‘blue’,‘red’],
Start_dt = [1,2,3],
End_dt = [3,4,5],
L = [0.8,1.8,2.8],
H= [1.2,2.2,3.2],
listaTag=[‘one’,‘two’,‘zero’])
)
listaTag=[‘one’,‘two’,‘zero’]
TOOLTIPS = [
(“index”, “$index”),
]
fig = Figure(plot_width=300, plot_height=300,name=“figure1”,tooltips=TOOLTIPS)
q1=fig.quad(left=‘Start_dt’, right=‘End_dt’, bottom=‘L’, top=‘H’,source=CDS,
color=‘Color’,tags=listaTag,name=‘quad1’)
fig.on_event(Tap,partial(callbackTapGantt,sorgente=CDS,nomeColonna=‘listaTag’,figura=fig))
layout = row(fig)
curdoc().add_root(layout)
Kind regards
Mauro


