question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Introducing iframe elements on v2

See original GitHub issue

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 wild iframe appeared in the DOM (causing issues with AdBlock, BTW).

Is v2 really introducing an iframe element when drawing graphs?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
etimbergcommented, Apr 3, 2016

@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 display: none; and then displayed (See #762 ).

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

3reactions
sknickcommented, Apr 18, 2016

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;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Introducing iframe elements on v2 #2210 - chartjs/Chart.js
The iframe solution works because it is set to be the same size as the canvas container node. Since the iframe is a...
Read more >
<iframe>: The Inline Frame element - HTML - MDN Web Docs
The <iframe> HTML element represents a nested browsing context, embedding another HTML page into the current one.
Read more >
The ultimate guide to iframes - LogRocket Blog
We'll go through most of the features the iframe element provides and talk about how you use them, as well as how iframe...
Read more >
The Magical <iframe> Tag: An Introduction - EasyRotator
It is the ultimate modularization tool, allowing you to break up content, seamlessly display content from other sources, and better manage ...
Read more >
4.8.2 The iframe element — HTML5 - W3C
The iframe element supports dimension attributes for cases where the embedded content has specific dimensions (e.g. ad units have well-defined ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found