ResponsiveContainer does not resize before printing
See original GitHub issueDo you want to request a feature or report a bug?
Bug
What is the current behavior?
When printing is initiated, ResponsiveContainer
re-uses the chart size from the window and does not scale properly regardless of the print specific outer container (green border) and ResponsiveContainer (red border) fixed dimensions.
If the current behavior is a bug, please provide the steps to reproduce
See screenshot
What is the expected behavior?
ResponsiveContainer should resize to the specified fixed dimensions.
Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?
1.0.0-beta.6, all browsers.
I understand printing may be out of scope of this project, but I am also hoping someone can offer a suggestion on how to solve this. After focusing on CSS-only solution which does not work since the chart is not resized, my next solution will be to listen to print events and conditionally set fixed dimensions although this solution is pretty messy and involved.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:12
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Recharts Responsive Container does not resize correctly in ...
I'm trying to create a custom collapsable legend for my data visualization app. It uses react and recharts.
Read more >Recharts Responsive Container does not resize correctly in ...
So far I have found no downsides to this, but YRMV. It seems rather hacky but a viable fix is to set width...
Read more >Responsive Charts - Chart.js
However, the resize won't happen automatically. To support resizing charts when printing, you need to hook the onbeforeprint (opens new window) ...
Read more >Responsive design - Learn web development | MDN
Creating a non-resizable web page by setting a fixed width doesn't work either; that leads to scroll bars on narrow devices and too...
Read more >Building responsive canvas apps - Power Apps - Microsoft Learn
Before you start using the responsive layouts, you need to do the following: ... Go to Settings > Display to disable Scale to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m having the same issue. The ResponsiveContainer is not responding to width changes on print.
My current solution (only tested on Chrome so far) is to trigger element resize via
@media print
For me to fix this issue I added css to change the default behavior of recharts when printing. Need to fix recharts “Legend” tag as well. Tested on Chrome, Safari and Edge