Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

highcharts prevent container being resized #5070

Closed
rubyisapm opened this issue Feb 23, 2016 · 9 comments
Closed

highcharts prevent container being resized #5070

rubyisapm opened this issue Feb 23, 2016 · 9 comments

Comments

@rubyisapm
Copy link

I use flex layout in my project, the chart's container is one of the subs of the flex container. Like as following:

<div id="flexContainer">
  <div id="firstSub">
  //another container
  </div>
  <div id="chartContainer">
  // chart's container
  </div>

</div>

On the page, user can resize the firstSub.
The problem is:
If the chart hasn't been rendered when resizing the firstSub, the chartContainer would follow the operation, but if the chat has been rendered when resizing the firstSub, the chartContainer wouldn't follow the operation. Like the chart prevents its container being resized( like it says: don't touch me!-_-!!)

@oysteinmoseng
Copy link
Member

Could you reproduce this issue in a jsFiddle demo?

@TorsteinHonsi
Copy link
Collaborator

Also see #4649

@rubyisapm
Copy link
Author

https://jsfiddle.net/rubyisapm/L5ftoctr/
This is the demo, you can click the button, you would find that the chart won't resize itself and seems like it prevent the left div to change the size. Thank you for your time.

@TorsteinHonsi
Copy link
Collaborator

Workaround

By setting the width of the container and the SVG, as well as calling chart.reflow after your modification, it seems to work: https://jsfiddle.net/highcharts/L5ftoctr/3/

@rubyisapm
Copy link
Author

Thank you so much for helping me out. @TorsteinHonsi :-)

@rubyisapm
Copy link
Author

Another problem, poor me!! See here: https://jsfiddle.net/rubyisapm/L5ftoctr/5/

first, hide the right container
after that, resize the left div
then, show the right container

you'll find the chart can't adapt the change. Even through I added the $(window).resize(), it didn't work either. Thank you

@TorsteinHonsi
Copy link
Collaborator

Does it help if you run chart.reflow()?

@rubyisapm
Copy link
Author

No, it doesn't work. But I found another way to fix it: I set the iframe's width from 100% to 99.9%, and it would trigger the iframe to resize itself, then the chart could reflow correctly. But if the chart is rendered in the main window, I'm afraid there hasn't no way I can think out to fix by now.

@sebastianbochan
Copy link
Contributor

You can try to call the setSize() method, which extracts width from container.
https://jsfiddle.net/da7cnfxe/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants