Kevin

Merge pull request #56 from nmdias/master

Added yLabelFormat property to define the y axis label formatting.
@@ -63,4 +63,9 @@ @@ -63,4 +63,9 @@
63 @property (nonatomic, strong) NSString *xUnit; 63 @property (nonatomic, strong) NSString *xUnit;
64 @property (nonatomic, strong) NSString *yUnit; 64 @property (nonatomic, strong) NSString *yUnit;
65 65
  66 +/**
  67 + * String formatter for float values in y labels. If not set, defaults to @"%1.f"
  68 + */
  69 +@property (nonatomic, strong) NSString *yLabelFormat;
  70 +
66 @end 71 @end
@@ -72,7 +72,8 @@ @@ -72,7 +72,8 @@
72 while (num > 0) { 72 while (num > 0) {
73 PNChartLabel *label = [[PNChartLabel alloc] initWithFrame:CGRectMake(0.0, (_chartCavanHeight - index * yStepHeight), _chartMargin, _yLabelHeight)]; 73 PNChartLabel *label = [[PNChartLabel alloc] initWithFrame:CGRectMake(0.0, (_chartCavanHeight - index * yStepHeight), _chartMargin, _yLabelHeight)];
74 [label setTextAlignment:NSTextAlignmentRight]; 74 [label setTextAlignment:NSTextAlignmentRight];
75 - label.text = [NSString stringWithFormat:@"%1.f", _yValueMin + (yStep * index)]; 75 + NSString *yLabelFormat = self.yLabelFormat ? self.yLabelFormat : @"%1.f";
  76 + label.text = [NSString stringWithFormat:yLabelFormat, _yValueMin + (yStep * index)];
76 [self addSubview:label]; 77 [self addSubview:label];
77 index += 1; 78 index += 1;
78 num -= 1; 79 num -= 1;
@@ -368,7 +369,7 @@ @@ -368,7 +369,7 @@
368 _yLabelNum = 5.0; 369 _yLabelNum = 5.0;
369 _yLabelHeight = [[[[PNChartLabel alloc] init] font] pointSize]; 370 _yLabelHeight = [[[[PNChartLabel alloc] init] font] pointSize];
370 371
371 - _chartMargin = 30; 372 + _chartMargin = 40;
372 373
373 _chartCavanWidth = self.frame.size.width - _chartMargin * 2; 374 _chartCavanWidth = self.frame.size.width - _chartMargin * 2;
374 _chartCavanHeight = self.frame.size.height - _chartMargin * 2; 375 _chartCavanHeight = self.frame.size.height - _chartMargin * 2;
@@ -61,6 +61,7 @@ @@ -61,6 +61,7 @@
61 lineChartLabel.textAlignment = NSTextAlignmentCenter; 61 lineChartLabel.textAlignment = NSTextAlignmentCenter;
62 62
63 PNLineChart * lineChart = [[PNLineChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)]; 63 PNLineChart * lineChart = [[PNLineChart alloc] initWithFrame:CGRectMake(0, 135.0, SCREEN_WIDTH, 200.0)];
  64 + lineChart.yLabelFormat = @"%1.1f";
64 lineChart.backgroundColor = [UIColor clearColor]; 65 lineChart.backgroundColor = [UIColor clearColor];
65 [lineChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5",@"SEP 6",@"SEP 7"]]; 66 [lineChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5",@"SEP 6",@"SEP 7"]];
66 67