eoinnorris / core-plot

Automatically exported from code.google.com/p/core-plot
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

CPTLegend columnWidths not honored in layout #517

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a CPTXYGraph with one or more CPTScatterPlots. Make sure the plots 
have titles that are fairly long.
2. Create a CPTLegend for those plots with one column and set 
"legend.columnWidths = @[[NSNumber numberWithFloat:50.0f]];
3. Anchor the legend to the graph on the right.

What is the expected output? What do you see instead?

I expect that the legend would take up no more than 50 points in width, because 
the desired column width is 50. Instead, the column width is set to the size of 
the largest plot title + swatch.

What version of the product are you using? On what operating system?

Core Plot 1.0 on iOS 5.1

Please provide any additional information below.

There appears to be a logic error in [CPTLegend recalculateLayout]. On line 
620, the line "if ( row < desiredColumnWidths.count ) {" is using the current 
row index to test against the columnWidths array size. I think the "col" index 
should be used instead. 
Then on line 623, it is assigning maxTitleWidth[col] to the MAX() of the 
computed width and the desired width. I think this should be using MIN(), so 
that the title size is never larger than the desired size.

I've attached my source file with these changes. 

Original issue reported on code.google.com by agood...@wingspan.com on 14 Mar 2013 at 2:04

GoogleCodeExporter commented 9 years ago
Line 620: This is a bug. Will fix.

Line 623: MAX is the intended behavior. The preferred size is the minimum 
column width; the final column width can be wider to fit the actual labels. 
Similar logic applies for the row heights. Won't fix.

Original comment by eskr...@mac.com on 16 Mar 2013 at 1:36

GoogleCodeExporter commented 9 years ago
This issue was closed by revision e1f3e732802b.

Original comment by eskr...@mac.com on 16 Mar 2013 at 1:38