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

Responsive resizing does not work sometimes ( hidden Iframe bug) #3521

Closed
freebees opened this issue Oct 27, 2016 · 7 comments
Closed

Responsive resizing does not work sometimes ( hidden Iframe bug) #3521

freebees opened this issue Oct 27, 2016 · 7 comments
Milestone

Comments

@freebees
Copy link

freebees commented Oct 27, 2016

chart.js Version: 2.3.0

Browsers: Chrome (51 fnd other), Firefox and other.

When we use ChartJS whis gridstack.js and bootstrap, sometimes we have an error whis hiddenIframe resizing. Sometimes resizing does not work.

What about replace this:

(hiddenIframe.contentWindow || hiddenIframe).onresize = function() { if (callback) { return callback(); } };

on this:

(window).onresize = function() { if (callback) { return callback(); } };
Its line 5776 chart.js

When we use window everithyng work fine.

@simonbrunel
Copy link
Member

Can you create a jsfiddle (or similar) that reproduce your issue?

Listening onresize on the iframe and the window is not the same: in the first case the chart will be resized when its parent container size changes, while in the second case, it will be resized only when the window size changes (which mean that if the chart container size changes programmatically, then it doesn't work).

Note that in 2.3, resizing vertically doesn't work but that's fixed in the upcoming version 2.4.

@freebees
Copy link
Author

freebees commented Oct 27, 2016

@simonbrunel
I make next:
(hiddenIframe.contentWindow || hiddenIframe).onresize = function() { console.log('test'); if (callback) { return callback(); } };
In the same moment of resizing I stopped to see test message.
But! If I set for iframe border: 1px red, I can see that even test message has been stopped, iframe still resizing, but canvas does not resizing.

I think, chartjs has got a conflict with material design html5 template that we use

Please, whatch my video: https://yadi.sk/d/sdHQaV1MxiF9Z
I am resizing the window. Red line over the chart is hidden iframe with red border.

@simonbrunel
Copy link
Member

Hard to say what's going on without a way to debug it :\ Is that page online, can you share it?

@freebees
Copy link
Author

@simonbrunel
I had shared
http://fattan.ru/chart/

Try to minimize browser width, and return width to normal size.

@simonbrunel
Copy link
Member

I see, the canvas and iframe elements are detached and re-attached to the DOM when your responsive layout changes, making the iframe content to reload (see the browser short loading state) and removing the "resize" even handler. Will include a fix in version 2.4.

@freebees
Copy link
Author

@simonbrunel
Can you tell me why you use iframe instead of (window).onresize?
We was surprised when we had seen that "resize" even handler was binding on iframe.

@simonbrunel
Copy link
Member

simonbrunel commented Oct 28, 2016

That's explained in my first reply! We plan to change that method in 2.5 with divs (and scroll events) instead of an iframe.

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

No branches or pull requests

3 participants