I am using an example for Cell Plot from here.
How do I add an event listener to the cell plot? I want to use mouse click on a cell, to get the x and y values to global variables.
Plot.plot({
marks: [
Plot.cell(cooccurrences, {
x: "item_a",
y: "item_b",
fill: "count",
title: d => `${d.item_a} + ${d.item_b} = ${d.count}`, // add tooltips for each cell
sort: { y: "fill", x: "fill", reverse: true, limit: 20 }
}),
// Add a textual annotation to each cell
Plot.text(cooccurrences, colorContrast({ // colorContrast is a transform that changes the text color for accessibility
x: "item_a",
y: "item_b",
text: "count",
fill: "count",
pointerEvents: "none", // make the text ignore the mouse pointer (so the cell tooltip works)
}))
],
x: { tickRotate: 90},
color: { scheme: "greens"},
marginLeft: 250,
marginRight: 100,
marginBottom: 200,
grid: true,
width
})