Add vertical span with a Taptool

Hello bokeh community :smiley:

I have a figure with multiple line plots in it. My goal is to be able to zoom in on a certain line and add a vertical span by clicking on the line. The span should go through the closest point in my line plot. After that, if I zoom back out again, I can see where it crosses the other line plots in the same figure. Kind of like a vertical crosshairtool, which stays on the plot when i save it and doesn’t move with the cursor when i zoom out. I think it should work with a taptool, but I don’t know how to set that up. I tried google and reading the docs for weeks but I don’t get it. I thought that this is a common usercase but i was wrong :frowning: I am thankfull for every piece of help I get.
regards Jimmy

@JimmySchenk I would suggest using a js_on_event callback with the "tap" event. The first example here shows just that. That example simply prints the x-coordinate in a console log. Instead you would set that x-coordinate as the value for the span (You would only create a single span up front, and have the callback update that one span).

There are lots of example of using JS callbacks to set other objects’ properties in that same chapter, and in the repo examples. If you run in to specific problems please post a Minimal Reproducible Example of the code you attempted.

@Bryan Thanks a lot. Funny is that i was looking at exact those examples but i didn’t get it. Somehow you made me look from a different position at it. I will add code the next time, but I thought it is cristall clear what i wanted.
You made my day :smiley:
Thanks, Jimmy

1 Like