Plot mark onclick handler

I expect this is already planned, but wondering if it is already possible at some level: can I attach an onclick hander to the visual representation of a mark? Specifically, I would like to set a mutable value. Ideally, this would look something like:

Plot.dotX(d3.range(5), {y:x=>x**2, fill:"red", r:10, onclick:x=>{mutable xclick=x;}})

I found this example of onclick implemented for an experimental tooltip mark that looks promising, but I don’t see this approach mentioned in the (very helpful) API docs.

Interactions are far from being ready. But since everything in Plot is functions and DOM, we can already play! Here’s a very experimental onclick plugin:

3 Likes

This is great, thanks @Fil! I appreciate that your solution is quite general and easily adaptable to similar tasks.

is there this func with typescript?)