The above code works as expected. Upon click, a data point is selected (coloured) in both graphs.
This topic was created in regard to the same functionality, but for scatter3d. If you change the trace type to ‘scatter3d’, the program crashes (caught in a on-click loop). The minimum example to showcase the error is as follows: