Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Rendering chart in a hidden container and with box-sizing #6617
The chart should be rendered the same was as when rendering in a visible container.
Width and height is miscalculated in
Live demo with steps to reproduce
Two different results, both wrong:
I'm not sure if there is a good fix for this at all... In order to keep all inherited CSS we would need to avoid cloning. Which would be good for performance too. See http://jsfiddle.net/highcharts/8e056mb2/2/.
In complex layouts this will probably result in a blink, but maybe that could be avoided by adding position:relative or other CSS tricks...
Well, the workaround is rather simply: just set CSS directly on the container, not using relative paths. The only problem is it's not easy to debug the issue (it took me about hour to find out what's happening, but I didn't have the access to CSS/JS - remote debugging).
I was thinking about copying over all computed CSS (not paths). For example: http://jsfiddle.net/8e056mb2/3/ (of course, this should happen before setting position/top/display).
I think that would be complicated and error prone, also due to different browser implementations of current style. The definately simplest and fastest approach would be to avoid cloning, but we need to temporarily make the chart visible without being visible to the eye. I'm pushing a fix where we temporarily give all the hidden parents
This is more or less the same approach as we're doing in 'Chart.print' where we isolate the chart by hiding all other children of the body, then reset them when the print is finished. It is a bit risky to modify the DOM like that, but is has been stable in the exporting module so it should be okay.