Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upIntroducing iframe elements on v2 #2210
Comments
This comment has been minimized.
This comment has been minimized.
|
@heruan v2 is adding an iframe. The reason an iframe is added is to detect when the canvas container resizes. There is a window resize event, which was used by v1, but it only detects when the entire window resized and not a specific element. This led to the problems of charts not displaying correctly when their container was initially I investigated a number of solutions for implementing better resize behaviour. Almost all of the available solutions use some combination of a timer / requestAnimationFrame. Unfortunately, this is bad for mobile battery life since we have to poll the size of the container continuously and check for a change. The iframe solution works because it is set to be the same size as the canvas container node. Since the iframe is a window, the window resize event can be listened to and then passed up out of the iframe to the chart to tell it when the container node resized. There is some other discussion on this topic in #2024 |
This comment has been minimized.
This comment has been minimized.
|
Thank you @etimberg for the clear explanation, it doesn't sound that bad for this purpose but unfortunately I'm having resize issues when using v2 in Single Page Applications based on Angular 2 and Aurelia. May it be because they build the DOM dynamically, injecting/removing elements while the user navigates the app? I'll build up a sample project and open separate issues! |
This comment has been minimized.
This comment has been minimized.
|
@herun if you could build up a sample project, that'd be great! I'm wondering if we can do the dom addition in a callback. The users could provide an overridden implementation that works with their framework (angular, react, etc) |
This comment has been minimized.
This comment has been minimized.
|
Issue reference: #2212 |
This comment has been minimized.
This comment has been minimized.
|
Just to add my $0.02 on this: The hidden iframe causes some issues for me when integrating Chart.js v2 into my Echo 3-based client-side application. Specifically, the insertion of the hidden iframe just before my canvas node prevents the canvas element from rendering properly (its height and width are left unset). My workaround is to disable resize listening: Chart.defaults.global.responsive = false; |
This comment has been minimized.
This comment has been minimized.
|
Continuing with what @sknick did I took it one step further and decided to use the global flag as the kill switch for the iframe. I read the comment in the src about binding so the responsiveness could be changed dynamically but in my case I cared less about that and more about the performance gain* I would receive by not having the iframe.
*Under "normal usage" I never saw a performance problem but I have an edge case scenario. We have 100+ little doughnut charts on the page and if someone were to change the filter on the data source it was taking much longer to reload than I was expecting. I knew it wouldn't be pretty I was surprised at the actual slowness. I noticed the favicon constantly flickering and started digging in. That's when I saw the iframe and tried to turn it off which lead me here. |
This comment has been minimized.
This comment has been minimized.
|
The hidden iframe introduces an accessibility issue as it raises the warning AX_FOCUS_01 "These elements are focusable but either invisible or obscured by another element". I think the warning may be mitigated by adding |
This comment has been minimized.
This comment has been minimized.
|
@metatribal where can I see that accessibility warning? |
This comment has been minimized.
This comment has been minimized.
|
I'm using the Google Accessibility Tool, here: On Sep 4, 2016 11:00 AM, "Simon Brunel" notifications@github.com wrote:
|
This comment has been minimized.
This comment has been minimized.
|
Thanks :) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I'm traveling right now; but will look at my laptop next time i get a On Sep 4, 2016 11:42 AM, "Simon Brunel" notifications@github.com wrote:
|
This comment has been minimized.
This comment has been minimized.
|
I'm reopening this since the use of an By default, there should be no wild |
This comment has been minimized.
This comment has been minimized.
|
Agree with you @heruan, but the default behavior can't be changed because it would break too many projects (at least for version 2.x). However, we are working on 2 main changes about chart responsiveness: at very short term (certainly v2.3.1), the iframe will not be injected anymore if |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Might need to reopen this. I have a chart in a scrollable div, and when the iframe is included in the DOM the canvas scrolls but nothing else does. When I manually remove the iframe from the DOM everything scrolls with the div correctly. I have a fixed height on a parent element, with 100% width. Unfortunately, setting the Before scrolling with
|
This comment has been minimized.
This comment has been minimized.
|
@johnmanko can you provide a live example of this issue? |
This comment has been minimized.
This comment has been minimized.
|
After additional testing, it looks like this may be a problem with a specific version of Chrome. The following version of Chrome everything works as it should: It works on Firefox. |




Since I'm planning to switch to v2 soon, I'm preparing a major update of our apps and I tried
v2.0.0-beta2: suddenly a wildiframeappeared in the DOM (causing issues with AdBlock, BTW).Is v2 really introducing an
iframeelement when drawing graphs?