5

When I execute this

Grid[{{x, x}, {SpanFromAbove, x}, {SpanFromAbove, x}}, 
 ItemSize -> {{Automatic}, 
  {Automatic, {1 -> Scaled[0.2], 2 -> Scaled[0.4], 3 -> Scaled[0.4]}}}, 
 Frame -> All, 
 Alignment -> {Center, Center}, Spacings -> {{2}, {1}}]

I get an extremely tall grid instead of a normal height grid. Is this a bug or am I doing something wrong? Version 10.0.1 Win8.1 64bit

Update

This just keeps getting worse. I am have used a Pane as some have suggested that the grid needs a sized container for it to work with Scaled. I get back a truncated grid. This is really baffling. Any ideas how to get this to work.

Pane[
 Grid[{{x, x}, {SpanFromAbove, x}, {SpanFromAbove, x}}, 
  ItemSize -> {{{Scaled[0.5]}}, 
   {Automatic, {1 -> Scaled[0.2], 2 -> Scaled[0.4], 3 -> Scaled[0.4]}}}, 
  Frame -> All, Alignment -> {Center, Center}, Spacings -> {{1}, {1}}], 
 ImageSize -> {432, 216}]

Mathematica graphics

It gives a cut off grid. ??? I can just make out the top of the "x" in the first column. It shouldn't be this difficult to have a grid a prescribed size and scale some rows within it. I must be doing something wrong.

Edmund
  • 42,267
  • 3
  • 51
  • 143
  • 1
    Unles you wrap Grid with something with set size, Scaled will refer to WindowSize. – Kuba Nov 24 '14 at 12:40
  • So I need to wrap it in a Pane or Panel and that will work? – Edmund Nov 24 '14 at 13:47
  • @Edmund The qustion is, what do you need? – Kuba Nov 24 '14 at 13:47
  • @Silvia Edmund set Item height not width. specx here is {Automatic} and it is width of items. But for specy he set explicitly 1->Scaled[.4] etc. what means "first row heigth 40% of enclosing region. – Kuba Nov 24 '14 at 13:51
  • 2
    @Silvia But I agree, the whole layout management is broken. For example here, Scaled takes something different into account: Framed["x", ImageSize -> {Scaled@1, Scaled@1}] – Kuba Nov 24 '14 at 13:53
  • @Kuba You're right! I must have read/written it with an automatic StringReplace[stuff, "width" -> "size"] built in my brain! :O – Silvia Nov 24 '14 at 14:01
  • @Kuba I have a chart in position {1,1} and some grids in each of the rows of column 2. I'd just like the rows in column 2 have heights as a percentage of the height Grid comes up with when ItemSize is omitted. When the chart is made its width is specified but height is Automatic so I don't know how tall it is. Also, the combined height of the 3 grid tables is greater than the height of the chart. I though Grid would use the total height it gets when no ItemSize option is given and then scale the rows using that height. But now I know it doesn't do this. – Edmund Nov 24 '14 at 17:09
  • @Edmund are you sure there is no way to get your chart height? It may be tough without that. Can't you specify it? – Kuba Nov 24 '14 at 18:09

1 Answers1

3

My advice, unless it is really basic problem, do not use SpanFrom~. Usually you will face "issues" like that. Next time try with nested Grids.

Like I've said, the whole layout management is broken and everyone who tried do something more complex than simple grid with automatic options will agree.

This is just another example, your case works if vertical heights sum up to: .5...

Framed[
 Grid[{
       {x, x},
       {SpanFromAbove, x},
       {SpanFromAbove, x}},
  ItemSize -> {
               {{Scaled@.499}},                  (*specX*)
               {Scaled@.1, Scaled@.2, Scaled@.2} (*specY*)
    }, Frame -> All, Alignment -> {Center, Center}, Spacings -> {0, 0}]
 , 
     ImageSize -> {432, 216}, FrameMargins -> 0, Alignment -> {Left, Top}]

enter image description here

Kuba
  • 136,707
  • 13
  • 279
  • 740