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

ChartJS and Flexbox not so responsive #4156

Closed
Zulfia73 opened this issue Apr 18, 2017 · 15 comments
Closed

ChartJS and Flexbox not so responsive #4156

Zulfia73 opened this issue Apr 18, 2017 · 15 comments

Comments

@Zulfia73
Copy link

Zulfia73 commented Apr 18, 2017

I have made a grid system using flex and now I insert some charts. And I try to use simple(display: flex).

Expected Behavior

When I increase the width of the screen, myChart must increase too and conversely, when i minimize .

Current Behavior

When I increase worked correct, but when minimize, myChart didn't minimized too

Possible Solution

I think. problem, that I use FlexBox, but answer i can't find.

@EmilMoe
Copy link

EmilMoe commented Apr 18, 2017

Flexbox is so poorly supported in IE that I would actually recommend you to avoid it.

Besides that I have had major issues with responsive and flexbox (in Firefox and Chrome).

@etimberg
Copy link
Member

I think this should work if you put a div inside the flexbox container and put the canvas inside that.

@simonbrunel thoughts?

@simonbrunel
Copy link
Member

@Zulfia73 @EmilMoe can you share a fiddle that showcase this issue?

@EmilMoe
Copy link

EmilMoe commented Apr 19, 2017

@simonbrunel I do not have any examples. Just added my experience that I had issues as well. I completely removed flexbox as it gives too many issues in IE and Edge.

As far as I remember the problem is that I need manually to redraw the graphs on resize when they are in flexbox.

@simonbrunel
Copy link
Member

It makes me think about the flex box and truncated text issue (specs): you should try to set min-width: 0 on the div (grid cells) containing charts (examples w/o min-width and w/ min-width).

@EmilMoe
Copy link

EmilMoe commented Apr 19, 2017

@simonbrunel it might work, I read about that as well, but unfortunately the support in IE and Edge is so poor that I decided to avoid flexbox.

@etimberg
Copy link
Member

etimberg commented May 2, 2017

Closing as out of date / answered per the conversation above

@etimberg etimberg closed this as completed May 2, 2017
@starpit
Copy link

starpit commented Nov 20, 2017

documenting this for future reference:

i am seeing this on chrome 59 (electron 1.7.9). when the chart is inside of a flex container, the initial size is fine. and the responsive bits respond well to increases in the size of the container. but the chart does not respond to decreases in container size. i note this also by attaching an onResize handler to the chart. i get callbacks for increases, but not for decreases.

https://jsfiddle.net/pgg9pz7c/1/

try growing the width of the window. observe that both charts respond well, growing in size; now try shrinking the width of the window. observe that only the lower chart responds well. the upper one, contained in a flexbox, does not respond to the shrinkage.

i also observe this behavior in firefox 57, in addition to the chrome embedded in electron 1.7.9

for future reference, the above suggestion of min-width: 0 seems to resolve this issue. not on the immediate container of the chart, but on the flex parent.

@simonbrunel
Copy link
Member

@starpit see my comment above (jsfiddle with min-width)

@starpit
Copy link

starpit commented Nov 20, 2017

thanks @simonbrunel

yes, the fix requires a min-width attr in the case of nested flex boxes. thanks!

@gtalarico
Copy link

Just wanted to say thanks to @simonbrunel as well
i have been trying to find a fix for this for a while... Thank you!

@mholt
Copy link

mholt commented Apr 20, 2018

Can confirm min-width: 0 on the container of the chart does the trick. Thanks @simonbrunel!

@mocon
Copy link

mocon commented Aug 1, 2018

Nice @simonbrunel, thank you!

@ghost
Copy link

ghost commented Feb 14, 2019

It makes me think about the flex box and truncated text issue (specs): you should try to set min-width: 0 on the div (grid cells) containing charts (examples w/o min-width and w/ min-width).

thanks for this!

@masaok
Copy link

masaok commented Aug 11, 2022

It makes me think about the flex box and truncated text issue (specs): you should try to set min-width: 0 on the div (grid cells) containing charts (examples w/o min-width and w/ min-width).

Thank you as well! Although, this solution did not specifically work for me, I found that overflow: auto did work, and it even works in your jsfiddle example (although it shows a flickering scrollbar in jsfiddle, so not it's probably not an optimal solution, but in my project, this solution works just fine).

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

10 participants