andi

some legend imporvements

@@ -269,6 +269,7 @@ @@ -269,6 +269,7 @@
269 CGFloat y = 0; 269 CGFloat y = 0;
270 270
271 /* accumulated width and height */ 271 /* accumulated width and height */
  272 + CGFloat totalWidth = 0;
272 CGFloat totalHeight = 0; 273 CGFloat totalHeight = 0;
273 274
274 NSMutableArray *legendViews = [[NSMutableArray alloc] init]; 275 NSMutableArray *legendViews = [[NSMutableArray alloc] init];
@@ -297,13 +298,14 @@ @@ -297,13 +298,14 @@
297 withWidth:maxLabelWidth 298 withWidth:maxLabelWidth
298 font:[UIFont systemFontOfSize:self.legendFontSize]]; 299 font:[UIFont systemFontOfSize:self.legendFontSize]];
299 300
300 - if (rowWidth + labelsize.width > mWidth) { 301 + if ((rowWidth + labelsize.width + beforeLabel > mWidth)&&(self.legendStyle == PNLegendItemStyleSerial)) {
301 rowWidth = 0; 302 rowWidth = 0;
302 x = 0; 303 x = 0;
303 y += rowMaxHeight; 304 y += rowMaxHeight;
304 rowMaxHeight = 0; 305 rowMaxHeight = 0;
305 } 306 }
306 - rowWidth += labelsize.width; 307 + rowWidth += labelsize.width + beforeLabel;
  308 + totalWidth = self.legendStyle == PNLegendItemStyleSerial ? fmaxf(rowWidth, totalWidth) : fmaxf(totalWidth, labelsize.width + beforeLabel);
307 // Add inflexion type 309 // Add inflexion type
308 [legendViews addObject:[self drawInflexion:legendCircle * .6 310 [legendViews addObject:[self drawInflexion:legendCircle * .6
309 center:CGPointMake(x + legendCircle / 2, y + singleRowHeight / 2) 311 center:CGPointMake(x + legendCircle / 2, y + singleRowHeight / 2)
@@ -327,7 +329,7 @@ @@ -327,7 +329,7 @@
327 counter ++; 329 counter ++;
328 } 330 }
329 331
330 - UIView *legend = [[UIView alloc] initWithFrame:CGRectMake(0, 0, mWidth, totalHeight)]; 332 + UIView *legend = [[UIView alloc] initWithFrame:CGRectMake(0, 0, totalWidth, totalHeight)];
331 333
332 for (UIView* v in legendViews) { 334 for (UIView* v in legendViews) {
333 [legend addSubview:v]; 335 [legend addSubview:v];