Kevin

Merge pull request #208 from klauslanza/klauslanza-lineChartYlabelFormatter

Line chart ylabel formatter block
@@ -66,6 +66,11 @@ @@ -66,6 +66,11 @@
66 */ 66 */
67 @property (nonatomic, strong) NSString *yLabelFormat; 67 @property (nonatomic, strong) NSString *yLabelFormat;
68 68
  69 +/**
  70 + * Block formatter for custom string in y-axis labels. If not set, defaults to yLabelFormat
  71 + */
  72 +@property (nonatomic, copy) NSString* (^yLabelBlockFormatter)(CGFloat);
  73 +
69 - (void)setXLabels:(NSArray *)xLabels withWidth:(CGFloat)width; 74 - (void)setXLabels:(NSArray *)xLabels withWidth:(CGFloat)width;
70 75
71 /** 76 /**
@@ -821,20 +821,26 @@ @@ -821,20 +821,26 @@
821 } 821 }
822 } 822 }
823 823
824 -  
825 - (NSString*) formatYLabel:(double)value{ 824 - (NSString*) formatYLabel:(double)value{
826 - if (!self.thousandsSeparator) { 825 +
827 - NSString *format = self.yLabelFormat ? : @"%1.f"; 826 + if (self.yLabelBlockFormatter)
828 - return [NSString stringWithFormat:format,value]; 827 + {
  828 + return self.yLabelBlockFormatter(value);
  829 + }
  830 + else
  831 + {
  832 + if (!self.thousandsSeparator) {
  833 + NSString *format = self.yLabelFormat ? : @"%1.f";
  834 + return [NSString stringWithFormat:format,value];
  835 + }
  836 +
  837 + NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
  838 + [numberFormatter setFormatterBehavior: NSNumberFormatterBehavior10_4];
  839 + [numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
  840 + return [numberFormatter stringFromNumber: [NSNumber numberWithDouble:value]];
829 } 841 }
830 -  
831 - NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];  
832 - [numberFormatter setFormatterBehavior: NSNumberFormatterBehavior10_4];  
833 - [numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];  
834 - return [numberFormatter stringFromNumber: [NSNumber numberWithDouble:value]];  
835 } 842 }
836 843
837 -  
838 - (UIView*) getLegendWithMaxWidth:(CGFloat)mWidth{ 844 - (UIView*) getLegendWithMaxWidth:(CGFloat)mWidth{
839 if ([self.chartData count] < 1) { 845 if ([self.chartData count] < 1) {
840 return nil; 846 return nil;