divyavamsee / core-plot

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

Legend best-fit width cut-off titles on iOS7 #596

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Setup an existing project with deployment target set to 7.0
2. Add a legend to an existing CPTXYGraph with more than one CPTScatterPlot 

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

The expected output is a legend showing the entire title. Instead, the legend 
cut-off some characters.

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

Core Plot 1.4 on iOS7

Please provide any additional information below.

It worked well on iOS6.
If I set the width manually with graph.legend.columnWidths I can see the entire 
tittle.

Original issue reported on code.google.com by dur...@gmail.com on 15 Oct 2013 at 7:13

Attachments:

GoogleCodeExporter commented 9 years ago
Is this on a device (which one?) or the simulator? Can you post your legend 
setup code to help duplicate the issue?

Original comment by eskr...@mac.com on 16 Oct 2013 at 12:30

GoogleCodeExporter commented 9 years ago
The problem occurs on both: I've tried on a device (iPhone 4S) and the 
simulator (3.5-inch and 4-inch). 

Here is my code (with some comments).

CPTMutableTextStyle *textStyle = [CPTMutableTextStyle textStyle];
textStyle.color = [CPTColor lightGrayColor];
textStyle.fontSize = 11.0;
// It also happends with System font.
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) 
textStyle.fontName = @"Bradley Hand";

graph.legend = [CPTLegend legendWithGraph:graph];
graph.legend.textStyle = textStyle;
graph.legend.swatchSize = CGSizeMake(20.0, 5.0);
// I had to setup number of Rows. Otherwise, on iOS7 CorePlot adds two rows. 
However, with two rows the titles are also cut-off.
graph.legend.numberOfRows = 1;

-----

If I setup rows with manually with:
graph.legend.columnWidths = [NSArray arrayWithObjects:[NSNumber 
numberWithInt:45], [NSNumber numberWithInt:50], [NSNumber numberWithInt:45], 
nil];
I can see the entire title. However, I can't distribute that way because titles 
change for each language.

Original comment by dur...@gmail.com on 16 Oct 2013 at 5:19

GoogleCodeExporter commented 9 years ago
Do you need any additional information? Can I test anything else? 

Original comment by dur...@gmail.com on 20 Oct 2013 at 7:04

GoogleCodeExporter commented 9 years ago
iOS 7 required us to switch to a new method of calculating the text size. It 
looks like there are slight differences between the calculated size and the 
size required to actually draw the text.

If you could provide one or more examples of labels that don't draw correctly 
in the default text style font, that would be helpful. We only need the string, 
not screenshots.

Original comment by eskr...@mac.com on 20 Oct 2013 at 12:24

GoogleCodeExporter commented 9 years ago
Some examples in the default text style font:

Systolic -> Cuts to "Systoli".
Diastolic -> Cuts to "Diastoli".
Pulse -> Cuts to "Puls".

Sistólica -> Cuts to "Sistólic".
Pulso -> Cuts to "Puls".

Sistòlica -> Cuts to "Sistòlic".
Pulsacions -> Cuts to "Pulsacion".

Original comment by dur...@gmail.com on 20 Oct 2013 at 5:38

GoogleCodeExporter commented 9 years ago
I cannot reproduce this problem in the Plot Gallery example app using the 
settings you provided. I tried it with bar plots and pie charts, using the 
system font, the text style default (Helvetica), and "Bradley Hand". All them 
rendered the text you provided correctly in the iOS 7 simulator (iPhone and 
iPad).

Please post the rest of the text style and legend setup code (if any). I want 
to make sure I'm testing with the exact same legend configuration.

Original comment by eskr...@mac.com on 21 Oct 2013 at 1:11

GoogleCodeExporter commented 9 years ago
There are no additional code to setup the legend or the text style. It cut-off 
titles on bar plots and line plots.

CPTMutableTextStyle *textStyle = [CPTMutableTextStyle textStyle];
textStyle.color = [CPTColor lightGrayColor];
textStyle.fontSize = 11.0;
//if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) 
textStyle.fontName = @"Bradley Hand";

graph.legend = [CPTLegend legendWithGraph:graph];
graph.legend.textStyle = textStyle;
graph.legend.swatchSize = CGSizeMake(20.0, 5.0);
// graph.legend.columnWidths = [NSArray arrayWithObjects:[NSNumber 
numberWithInt:45], [NSNumber numberWithInt:50], [NSNumber numberWithInt:45], 
nil];
graph.legend.numberOfRows = 1;

--- 

That's how I setup the graph:

// Create graph from theme
graph = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
CPTTheme *theme = [CPTTheme themeNamed:kCPTPlainBlackTheme];
[graph applyTheme:theme];

CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view;
hostingView.collapsesLayers = NO; // Setting to YES reduces GPU memory usage, 
but can slow drawing/scrolling
hostingView.hostedGraph = graph;    

// Add plot space for bar charts
CPTXYPlotSpace *barPlotSpace = [[CPTXYPlotSpace alloc] init];
barPlotSpace.allowsUserInteraction = NO;

Original comment by dur...@gmail.com on 21 Oct 2013 at 4:55

GoogleCodeExporter commented 9 years ago
I still cannot reproduce this problem. Are you seeing similar issues anywhere 
else?

Original comment by eskr...@mac.com on 25 Oct 2013 at 12:35

GoogleCodeExporter commented 9 years ago
It only happens on legends. I will gather more info to reproduce the problem.

Original comment by dur...@gmail.com on 2 Nov 2013 at 9:36

GoogleCodeExporter commented 9 years ago
Setting constant column width solved my similar issue (I put 
graph.legend.columnWidths = @[@300]; for 1 column legend).

Original comment by fp.mobil...@gmail.com on 20 Nov 2013 at 2:15

GoogleCodeExporter commented 9 years ago
I too have been tearing what little hair I have left out trying to get the 
legend captions to fit inside the frame of the legend. Many thanks for the 
suggestion about setting the column width. That works for me too.

In the future, perhaps there should be an additional attribute for the size of 
the legend box.

Original comment by myoung...@gmail.com on 21 Nov 2013 at 5:05

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

Original comment by eskr...@mac.com on 23 Nov 2013 at 12:47