Draggin a Span bar

I am trying to have a span bar on my bokeh plot that can be dragged across a plot by a user. As I slides it would show a different value, e.g. the cumulative integral of the function.

There are PanStart, Pan, and PanEnd events in bokeh.events that you could respond to with either JavaScript or (in a Bokeh server app) Python callbacks to update the coordinates of a span (and also trigger some computation, etc). I don’t have any complete example to share offhand.

I will say if you can settle for a user clicking somewhere, and moving the span in response to the click. that’s probably considerably simpler logic than handling the click/drag interactions.

Alternatively, the PolyDrawTool will let users drag and move a multi-line out of the box, however:

  • you may not want the other features it provides, e.g. deleting the line
  • it cannot be infinite like a span