Selecting single point with taptool

Hi, I’d ideally like it if when using the taptool, I could make it select only a single point rather than multiple points, for example if the size is large and there is some overlap between the points. Obviously you wouldn’t normally want to have large points shown that overlap but in my case there’re 10000’s of points and the axis are variably sized so it’s inevitable that there is some overlap. In my code I’ve added some if/else code to check whether multiple points have been selected and if it’s multiple, to drop it down to one. However this still means that this code has to run through which slows it all down a bit, plus it shows all of them, then after a bit shows only one which isn’t as neat and tidy as I’d ideally like it to be. I’ve copied in some example jupyter code below where there’s some overlap between the points and clicking on the data in this region causes it to highlight multiple points.

Therefore my question - is there any way to make taptool select a single point by default (closest to the click point, first, last, whatever)? Same thing applies for the hovertool in fact where it can show multiple sets of information. Thanks very much in advance.

from bokeh.plotting import figure, show,output_notebook
from bokeh.models import TapTool

Not at present, this is still an open issue:

At present your best bet is as you have already described, i.e. to prune the results wherever you are processing the selection (with CustomJS if you are not using a Bokeh server app)

Thanks for the reply. Do you think there would be a preference in terms of speed/performance depending upon whether it’s done on the python side or via customjs? Currently I’m running a python callback but…

It’s not really possible to speculate on specific improvements without seeing and understanding what you are already doing, in detail. Can you provide a Minimal Reproducible Example that demonstrates the approach you are using now?