iOS7 not legend shown


#1

Hello.

Under iOS 6 and bellow and iOS7, my piecharts present fine and correctly. The problem is that under iOS7 there is no legend under the piechart, there is only the border of the legend, but no legend is inside. Something interesting is that the border of the legend’s frame is very small compared to the frame when its correctly displayed. Any ideas or tweak ?.

Regards

Gustavo


#2

Hi Gustavo,

When I run the PieChart sample packaged with the framework my legend displays as expected. Could you provide your chart & legend setup code? I’ll try and replicate the issue on my end.

Jan


#3

Hello Jan.

Here is the code:

//…

    SChartTheme * theme = [SChartMidnightThemenew];
    
     theme.chartStyle.backgroundColor = [UIColorclearColor];
     theme.chartStyle.backgroundColorGradient = [UIColorclearColor];
     theme.chartStyle.borderColor = [UIColorclearColor];
     [(SChartMidnightTheme *)theme setMidnight_greyColorLowAlpha:[UIColorclearColor]];
    [(SChartMidnightTheme *)theme setMidnight_greyColor:[UIColor clearColor]];
    [theme.legendStyle setBorderColor:[UIColor lightGrayColor]];
    [theme.legendStyle setCornerRadius:[NSNumber numberWithDouble:3.0f]];

//…

    self.pieChart.legend.hidden = NO;
     self.pieChart.autoresizingMask = ~UIViewAutoresizingNone;    
     UITapGestureRecognizer *tap = [[UITapGestureRecognizeralloc] initWithTarget:selfaction:@selector(legendClick:)];
     [self.pieChart.legendaddGestureRecognizer:tap];
     [self.pieChart.legend.stylesetTextAlignment:UITextAlignmentRight];
     self.pieChart.legend.autosizeLabels = YES;
     self.pieChart.legend.style.font = [UIFontfontWithName:@"HelverticaNeue-Light"size:12];
     self.pieChart.legend.position = SChartLegendPositionBottomMiddle;
 
 
 I dunno if that gesture recognizer has something to do with the problem.
 The tap gesture recognizer was implementeing acording a blog your have to add user interactivity to the legend.
 
 Gustavo

#4

Hi Gustav,

You have a typo in the line that sets the font on the pieChart. Try replacing @“Helve r ticaNeue-Light” with @“HelveticalNeue-Light” as currently you are assigning a nil font to your legend. (Nil is the return value when a font doesn’t exist.)

We use the font to calculate the size that the legend needs to be and the nil font is messing up these calculations. The chart’s legend should probably fall back to a default font if a nil font is set on it, so I’ve raised this as an issue!

Thanks,
Jan


#5

Im an idiot! .:stuck_out_tongue:

Thanks for the remark.


#6

No problem. Glad I could help!


#7

Hi there 

I’m trying to show the legend on my bar chart but only the border is shown.

iOS%20Simulator%20-%20iPhone%20Retina%20(4-inch)%20/%20iOS%207.1%20(11D167)

This is my code 

intraix%20%E2%80%94%20UtilitiesDashboardTableViewController.m Love to get some advise here :smiley: Thank you


#8

Hi there :slight_smile:

anyone to advise on the legend moving way out of the plot area?

Thank you 


#9

bumped  :scream: :scream: :scream:


#10

Hi bosslee,

Sorry to hear you’re having this issue! I can’t see anything wrong with the code you have posted. Although it does look like there’s a lot of space between the x-axis and the top of the legend - do you happen to have an x-axis title set?

Also, knowing how/when the frame of your chart is set might give us some clues.


#11

Actually, ignore my above post - this issue was fixed in v2.6.1, so our most recent version of the framework should be free of this issue.  :laughing: