shauns / react-d3-radar

React-based Radar chart for D3
MIT License
53 stars 32 forks source link

onHover not working #12

Open mturnwall opened 5 years ago

mturnwall commented 5 years ago

Hi, I'm trying to use this for an interactive radar chart. It has all functionality I need. Unfortunately the onHover method isn't working for me. I tried using your exact code from your example in the README.

Here is an example of what I'm doing, https://codesandbox.io/s/r0j22wl76p

shauns commented 5 years ago

Hi @mturnwall ! I have forked your sandbox and made two changes that sort things out:

Firstly I downgraded to the non-RC version of the repo. It's still WIP and has some issues around internal SVG transforms and mapping to hovered points.

I also changed how you've used the highlighted prop. It's a controlled component, so you have to tell it what point to highlight. So the flow is: user moves over a point > onHover prop called > you do something with that -- typically setting state like I've done in the sandbox > you update other props, like highlighted.

I hope that helps!

Do you mind me asking what you're working on?

shauns commented 5 years ago

The link would be useful too :D https://codesandbox.io/s/94zyqrly8p