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

min_width calculation in cells.rb wrong #326

Closed
angelomichel opened this issue Feb 17, 2012 · 1 comment
Closed

min_width calculation in cells.rb wrong #326

angelomichel opened this issue Feb 17, 2012 · 1 comment

Comments

@angelomichel
Copy link

I cannot fully explain why, but I can show (by logging results how) "def min_width" (which basically calls "aggregate_cell_values(:column, :avg_spanned_min_width, :max)") gives false returns in the following case.

Lets say I have a table which is 400 in width.
Column_widths are: [ 90, 160, 44, 53, 53 ](aka 400)

In my data table I say something like
[
["a", {content: "b", colspan:2}, "d","e"],
["f","g","h","i",j"]
]

If you log every Cell.rb -> avg_spanned_min_width, you get the following results:
Cell.rb#avg_spanned_min_width -> min_width / colspan (90 / 1) = 90.0
Cell.rb#avg_spanned_min_width -> min_width / colspan (204 / 2) = 102.0
Cell.rb#avg_spanned_min_width -> min_width / colspan (204 / 2) = 102.0
Cell.rb#avg_spanned_min_width -> min_width / colspan (53 / 1) = 53.0
Cell.rb#avg_spanned_min_width -> min_width / colspan (53 / 1) = 53.0
Cell.rb#avg_spanned_min_width -> min_width / colspan (90 / 1) = 90.0
Cell.rb#avg_spanned_min_width -> min_width / colspan (160 / 1) = 160.0
Cell.rb#avg_spanned_min_width -> min_width / colspan (44 / 1) = 44.0
Cell.rb#avg_spanned_min_width -> min_width / colspan (53 / 1) = 53.0
Cell.rb#avg_spanned_min_width -> min_width / colspan (53 / 1) = 53.0
Cell.rb#avg_spanned_min_width -> min_width / colspan (90 / 1) = 90.0

this is from cell.rb (not cell s .rb) (and sorry for the text above, it's from my log)

The returning value in aggregate is:
Cells.rb#aggregate_cell_values values -> [90.0, 160.0, 102.0, 53.0, 53.0]

And here is the error. the 2nd and 3rd value should match 102.0, 102.0 beause of the colspan OR should match 160.0, 44.0 without the colspan.

This has to do with the :max (102.0 is higher than 44.0 so it takes 102.0 at the 3rd position, while 160.0 is higher than 102.0, so it takes that).

I am not sure how to fix it, but is must be some solution which accounts for colspan columns (or makes an average instead of max).

This is, to me a real issue, because I cannot use colspan in my case. If anyone knows a quickfix (or even better full fix), please submit :)

@yob
Copy link
Member

yob commented Dec 8, 2012

Thanks for the report.

issue #407 appears to be reporting this same issue and has some discussion. I'll close this issue in favour of that one.

@yob yob closed this as completed Dec 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants