d3fc-webgl-hathi-explorer icon indicating copy to clipboard operation
d3fc-webgl-hathi-explorer copied to clipboard

How to add onClick event to each point

Open velusian opened this issue 3 years ago • 2 comments

Hello, I'm trying to add an "onClick" event to each point, but cannot find any documentation on how to do so. The latest version of d3fc is 15.2 but I can only found docs on v. 13. Can you please help? Thank you!

velusian avatar Jan 17 '22 08:01 velusian

You get click events with DOM (or SVG nodes), however, they don't exist for Canvas or WebGL. This plot uses WebGL, so hence they are not triggered!

You'll have to 'synthesise' this event yourself, by monitoring mouse location and clicks - see:

https://github.com/ColinEberhardt/d3fc-webgl-hathi-explorer/blob/master/index.js#L117

ColinEberhardt avatar Jan 20 '22 10:01 ColinEberhardt

OK thank you Colin, I knew this technique for Canvas but not for WebGL.

velusian avatar Jan 20 '22 14:01 velusian