Observable Plot click events

Does Observable Plot support click events, and how can I add a click event to each dot on the plot?

It’s not very easy today, but you can do it with a render transform:

1 Like

Thank you very much for your patient answer. This method has solved my problem.

1 Like

Is there work being done to advance this? Very interested, but current solution are clunky.

Remaking an old chart here but I want to print the slopes when a user clicks.

My old solution pre-Plot() is here

No progress since last time, I’m afraid!

I don’t think this solves your problem (or sym0’s), but, if others come across this, I should note that all marks do support an href channel (see Mark options) that makes marks into links. E.g., in this example, you can click an earthquake to see details on the USGS website:

Plot.plot({
  projection: "equirectangular",
  style: "overflow: visible;",
  marks: [
    Plot.geo(land, {fill: "currentColor", fillOpacity: 0.2}),
    Plot.sphere(),
    Plot.geo(earthquakes, {
      r: (d) => Math.pow(10, d.properties.mag),
      fill: "red",
      fillOpacity: 0.2,
      stroke: "red",
      title: (d) => d.properties.title,
      href: (d) => d.properties.url,
      target: "_blank"
    })
  ]
})