olunx

Add options for chart legend font style.

... ... @@ -25,7 +25,8 @@ typedef NS_ENUM(NSUInteger, PNLegendItemStyle) {
@property (assign, nonatomic) BOOL hasLegend;
@property (assign, nonatomic) PNLegendPosition legendPosition;
@property (assign, nonatomic) PNLegendItemStyle legendStyle;
@property (assign, nonatomic) CGFloat legendFontSize;
@property (assign, nonatomic) UIFont *legendFont;
@property (assign, nonatomic) UIColor *legendFontColor;
/**
* returns the Legend View, or nil if no chart data is present.
... ...
... ... @@ -821,13 +821,13 @@
* should be in the middle of the first row */
CGFloat singleRowHeight = [PNLineChart sizeOfString:@"Test"
withWidth:MAXFLOAT
font:[UIFont systemFontOfSize:self.legendFontSize]].height;
font:self.legendFont ? self.legendFont : [UIFont systemFontOfSize:12.0f]].height;
for (PNLineChartData *pdata in self.chartData) {
/* Expected label size*/
CGSize labelsize = [PNLineChart sizeOfString:pdata.dataTitle
withWidth:maxLabelWidth
font:[UIFont systemFontOfSize:self.legendFontSize]];
font:self.legendFont ? self.legendFont : [UIFont systemFontOfSize:12.0f]];
/* draw lines */
... ... @@ -869,7 +869,8 @@
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x + legendLineWidth, y, maxLabelWidth, labelsize.height)];
label.text = pdata.dataTitle;
label.font = [UIFont systemFontOfSize:self.legendFontSize];
label.textColor = self.legendFontColor ? self.legendFontColor : [UIColor blackColor];
label.font = self.legendFont ? self.legendFont : [UIFont systemFontOfSize:12.0f];
label.lineBreakMode = NSLineBreakByWordWrapping;
label.numberOfLines = 0;
x += self.legendStyle == PNLegendItemStyleStacked ? 0 : labelsize.width + legendLineWidth;
... ...
... ... @@ -277,13 +277,13 @@
* should be in the middle of the first row */
CGFloat singleRowHeight = [PNLineChart sizeOfString:@"Test"
withWidth:MAXFLOAT
font:[UIFont systemFontOfSize:self.legendFontSize]].height;
font:self.legendFont ? self.legendFont : [UIFont systemFontOfSize:12.0f]].height;
for (PNPieChartDataItem *pdata in self.items) {
/* Expected label size*/
CGSize labelsize = [PNLineChart sizeOfString:pdata.textDescription
withWidth:maxLabelWidth
font:[UIFont systemFontOfSize:self.legendFontSize]];
font:self.legendFont ? self.legendFont : [UIFont systemFontOfSize:12.0f]];
// Add inflexion type
... ... @@ -293,7 +293,8 @@
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x + legendCircle, y, maxLabelWidth, labelsize.height)];
label.text = pdata.textDescription;
label.font = [UIFont systemFontOfSize:self.legendFontSize];
label.textColor = self.legendFontColor ? self.legendFontColor : [UIColor blackColor];
label.font = self.legendFont ? self.legendFont : [UIFont systemFontOfSize:12.0f];
label.lineBreakMode = NSLineBreakByWordWrapping;
label.numberOfLines = 0;
x += self.legendStyle == PNLegendItemStyleStacked ? 0 : labelsize.width + legendCircle;
... ...
... ... @@ -80,7 +80,8 @@
[self.view addSubview:self.lineChart];
self.lineChart.legendStyle = PNLegendItemStyleStacked;
self.lineChart.legendFontSize = 12.0;
self.lineChart.legendFont = [UIFont boldSystemFontOfSize:12.0f];
self.lineChart.legendFontColor = [UIColor redColor];
UIView *legend = [self.lineChart getLegendWithMaxWidth:200];
[legend setFrame:CGRectMake(100, 400, legend.frame.size.width, legend.frame.size.width)];
... ... @@ -153,7 +154,7 @@
self.pieChart.legendStyle = PNLegendItemStyleStacked;
self.pieChart.legendFontSize = 12.0;
self.pieChart.legendFont = [UIFont boldSystemFontOfSize:12.0f];
UIView *legend = [self.pieChart getLegendWithMaxWidth:200];
[legend setFrame:CGRectMake(100, 400, legend.frame.size.width, legend.frame.size.width)];
... ...