How to retrieve selection coordinates from selection geometry event

Hey. I’m trying to retrieve the geometry dict from the selectiongeometry event but I can’t find a way to do it.


p = figure(plot_width=1100, plot_height=500, tools="xpan, save, zoom_in, zoom_out, ypan", x_range=(0, 100), tooltips=TOOLTIPS)
p.line(x='x', y='y', source=s1, color="blue", line_width=1, line_alpha=0.4)
stats = PreText(text="", width=500)

I already managed to update the PreText upon selection, but I would like to get the start and end (x0, x1) coordinates in order to retrieve that data based on the selection coordinates

stats = PreText(text="", width=500)

def update_stats(event):
    stats.text = "selection event."
p.on_event('selectiongeometry', update_stats)

r1 = row(p, stats)
c1 = column(peek)
c2 = column(r1, c1)


Maybe there is another way to get the and store the selected data?

I would suggest printing event.geometry in your callback so that you can observe its structure and contents.

1 Like

Was it that simple…? :laughing:

Thank you Bryan.

1 Like