react-google-charts icon indicating copy to clipboard operation
react-google-charts copied to clipboard

How to click on a pie chart and got to a url with react-router.

Open charliema7 opened this issue 4 years ago • 1 comments

Hi, I'm a total newbie and I'm having a lot of trouble trying to figure out how to work with react-router inside a chartEvents. I want to be able to click on a slice of pie chart and have it go to a route depending on what slice I click on. I can do it with windows.location.href, but it re-renders the entire page, instead of just the component. This is a class component I'm working in.

Much thanks for your help!

charliema7 avatar Jun 14 '20 10:06 charliema7

I doubt this is an issue with react-google-charts but you can define an onClick on the pie chart and in that onClick you can do let location = useHistory();location.push("/whereverYouWantToGo")

MeanManMachineMan avatar May 12 '21 07:05 MeanManMachineMan