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

Reflow of the chart inside table #1157

Closed
pawelfus opened this issue Aug 8, 2012 · 14 comments
Closed

Reflow of the chart inside table #1157

pawelfus opened this issue Aug 8, 2012 · 14 comments
Labels
Status: Has workaround Status: Stale This issue hasn't had any activity for a while, and will be auto-closed if no further updates occur. Type: Undecided

Comments

@pawelfus
Copy link
Contributor

pawelfus commented Aug 8, 2012

Example: http://jsfiddle.net/FzXEM/

When resizing iframe/window chart reflow fine when makes it bigger, but doesn't reflow when makes it smaller.

Possible workaround: use setSize() method: http://jsfiddle.net/FzXEM/1/

@TorsteinHonsi
Copy link
Collaborator

Not sure whether to call this a bug. The chart prevents the container from shrinking.

The pure CSS workaround is to set position:absolute and width: 100% on the container, then it won't affect the layout of the table cell: http://jsfiddle.net/highcharts/rLq7R/

@sjakops
Copy link

sjakops commented Aug 16, 2012

I'm not sure if absolute positioning will work - what if I have some content below that row? Seems it will be overwritten by the chart: http://jsfiddle.net/zLxRu/1/

Anyway, I think it is a bug in the sense that I would expect highcharts to work the same whether the container is a div or a table cell (divs are not prevented from shrinking).

@TorsteinHonsi
Copy link
Collaborator

If you give the table cell a height it works:
http://jsfiddle.net/highcharts/zLxRu/2/

@sjakops
Copy link

sjakops commented Aug 16, 2012

and what if I need the table cell to dynamically adapt to the height of the chart?:) (I do..)

@sjakops
Copy link

sjakops commented Aug 27, 2012

are there any plans to fix this issue?

@TorsteinHonsi
Copy link
Collaborator

Well, not currently... Here's a way to let the height of the table cell adapt to the chart: http://jsfiddle.net/highcharts/zLxRu/3/

@sjakops
Copy link

sjakops commented Aug 28, 2012

Thanks for a solution again, though this one had some side effects on padding/margin of containing elements - was trying to solve this by using setSize, which however required some bookkeeping of chart objects, and in the end it somehow was not possible to get the correct current cell size.. Turned out an easier hack was to catch the window's resize event and set the size of the containing cell when the event fires (as I am using em sizes I had to add a dummy div from which to get the correct size including margin/padding (jquery width() only returns pixel values))

@onemenny
Copy link

this is very frustrating - i cannot seem to find a solution either: http://forum.highcharts.com/highcharts-usage/chart-not-responsive-in-display-table-t32424/

it should be handled automatically by highcharts and not by external JS. the proposed solution is only half way there, cause you need to consider other DOM elements along the way with their padding and margin...

this should be fixed by highcharts and not by the users

@TorsteinHonsi
Copy link
Collaborator

The problem is that the chart is an SVG image and behaves like any other image inside a table cell. While expanding the table, it works well because the table cell actually expands to, so our logic picks it up and upsizes the chart image. But when contracting the table, the image sits there and blocks the cell, so it won't get smaller than the image. So our model of adapting the SVG size to the table cell makes no difference.

@onemenny
Copy link

Thanks @highslide-software
Your answer, as usual, is something i can live with understanding the cause. very different from the "throw away" i got in your forums.

at the end i managed to mimick the table behavior using flex and min-height styles...

@dluk
Copy link

dluk commented Sep 4, 2015

solution for this was adding this to css:
.highcharts-container, .highcharts-container svg { width: 100% !important; }
Edit: noticed it didn't work with Firefox, so needed to add
table { table-layout: fixed; }
see the example: http://jsfiddle.net/FzXEM/10/

@TorsteinHonsi
Copy link
Collaborator

Thanks for the fix, that's a good one!

@nawlbergs
Copy link

@dluk This mostly works... but I am still having issues when I have multiple columns of charts in a table. Id post a fiddle but my code is thiiiiick.

@stale
Copy link

stale bot commented Aug 22, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

@stale stale bot added the Status: Stale This issue hasn't had any activity for a while, and will be auto-closed if no further updates occur. label Aug 22, 2021
@stale stale bot closed this as completed Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Has workaround Status: Stale This issue hasn't had any activity for a while, and will be auto-closed if no further updates occur. Type: Undecided
Projects
None yet
Development

No branches or pull requests

8 participants