d3-render icon indicating copy to clipboard operation
d3-render copied to clipboard

Accessing 'data' in on* events (for tooltips)

Open CobusT opened this issue 3 years ago • 1 comments

In d3, when I process an event like mouseOver, the data passed into the event is the data that is bound to the DOM element. When using d3-render, when I look at the data that is passed to the event, it is actually the data for d3-render element and not the actual data used to generate the render data.

For example, in d3, on a mouseover event, I can get the value to display in a tooltip to be the actual data (using d): image so I can show d.value

But when I look at the d passed to the event in d3-render, it is image

Any suggestions for how to get to the actual d.value?

This may not be possible, because the data is abstracted away from the rendering, but that poses a bit of a challenge for how to render tooltips...

CobusT avatar Feb 17 '21 23:02 CobusT

Hi, Could you try something like this? (from a bar chart example) image Basically pass d manually into the onClick function

unkleho avatar Feb 23 '21 11:02 unkleho