Getting coordinates of hovered data point in CustomJS

It is possible to execute JavaScript code when the plot is clicked using a Tap event and CustomJS:

from bokeh.plotting import figure
from bokeh.events import Tap

p = figure(...)
p.js_on_event(Tap, CustomJS(args = args, code = js_code))

With cb_obj.x in the js_code JavaScript code, I can access the x-value of the data coordinates where the mouse pointer click happened in the plot.

Is there a way to get the x-value of the closest data point which is currently hovered? Of course this would only work if hovering is enabled and when the mouse pointer is close enough to a data point.

In a JS callback from CustomJSHover, there is the special_vars variable which provides the coordinates of the hovered data point with the data_x property. However, it seems that special_vars is not available in the CustomJS callback of a Tap event.

I don’t think so. The last time I needed that, I had to search for the closest point myself.