Closed john-rock closed 3 years ago
Hi there, thanks for the response.
The link below is the component I am using the download feature on. The code in question starts on line 70. Feel free to clone and see the behavior there.
https://github.com/john-rock/benfords-law/blob/download-chart/src/components/Chart.js
Thanks for the repo. I'm not getting an empty png, but I think there may be some browser compatibility issues. Something is causing half of the png to be cut off in Chrome/Edge.
Here's the download in Chrome 86:
Here it is is Edge 86:
And here's what it looks like in Firefox 78.4esr:
I noticed you are using <ResponsiveContainer>
, so I updated my Codesandbox in https://github.com/brammitch/recharts-to-png/issues/4#issuecomment-724848962 to use it as well, and it still works fine.
I'd dig into your styles/css to see if you can find out what is causing the issue, or you can pass in a y-offset
to see if you can move the image into place, like so:
const pngData = await getPngData(chart, {
y: 500
});
Interesting, thanks for the quick response again.
I'll poke around and follow up with my findings.
I ended up getting this to work correctly by moving the ref from the chart component and on to the container div as well as using the y offset option.
The downloaded chart is now viewing correct across all browsers.
Awesome. Glad you were able to get it working!
Hello, are composed charts supported?
I have a bar and line graph inside a composed chart. After following the directions, it will only download an empty png.