Kevin

Merge pull request #62 from jackyzonewen/master

PNLineChart's inflexion Point support two sharp, such as cycle, square
@@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
10 #import <QuartzCore/QuartzCore.h> 10 #import <QuartzCore/QuartzCore.h>
11 #import "PNChartDelegate.h" 11 #import "PNChartDelegate.h"
12 12
13 -  
14 @interface PNLineChart : UIView 13 @interface PNLineChart : UIView
15 14
16 /** 15 /**
@@ -48,8 +47,6 @@ @@ -48,8 +47,6 @@
48 47
49 @property (nonatomic) CGFloat chartMargin; 48 @property (nonatomic) CGFloat chartMargin;
50 49
51 -  
52 -  
53 @property (nonatomic) BOOL showLabel; 50 @property (nonatomic) BOOL showLabel;
54 51
55 52
This diff is collapsed. Click to expand it.
@@ -5,14 +5,36 @@ @@ -5,14 +5,36 @@
5 5
6 #import <Foundation/Foundation.h> 6 #import <Foundation/Foundation.h>
7 7
  8 +/**
  9 + * not support PNLineChartPointStyleTriangle style recently
  10 + */
  11 +typedef NS_ENUM(NSUInteger, PNLineChartPointStyle) {
  12 +
  13 + PNLineChartPointStyleNone = 0,
  14 + PNLineChartPointStyleCycle,
  15 + PNLineChartPointStyleTriangle,
  16 + PNLineChartPointStyleSquare
  17 +};
  18 +
8 @class PNLineChartDataItem; 19 @class PNLineChartDataItem;
9 20
10 typedef PNLineChartDataItem *(^LCLineChartDataGetter)(NSUInteger item); 21 typedef PNLineChartDataItem *(^LCLineChartDataGetter)(NSUInteger item);
11 22
12 -  
13 @interface PNLineChartData : NSObject 23 @interface PNLineChartData : NSObject
14 24
15 @property (strong) UIColor *color; 25 @property (strong) UIColor *color;
16 @property NSUInteger itemCount; 26 @property NSUInteger itemCount;
17 @property (copy) LCLineChartDataGetter getData; 27 @property (copy) LCLineChartDataGetter getData;
  28 +
  29 +@property (nonatomic, assign) PNLineChartPointStyle inflexionPointStyle;
  30 +
  31 +/**
  32 + * if PNLineChartPointStyle is cycle, inflexionPointWidth equal cycle's diameter
  33 + * if PNLineChartPointStyle is square, that means the foundation is square with
  34 + * inflexionPointWidth long
  35 + */
  36 +@property (nonatomic, assign) CGFloat inflexionPointWidth;
  37 +
  38 +@property (nonatomic, assign) CGFloat lineWidth;
  39 +
18 @end 40 @end
@@ -7,4 +7,22 @@ @@ -7,4 +7,22 @@
7 7
8 @implementation PNLineChartData 8 @implementation PNLineChartData
9 9
  10 +- (id)init
  11 +{
  12 + self = [super init];
  13 + if (self) {
  14 +
  15 + [self setDefaultValues];
  16 + }
  17 +
  18 + return self;
  19 +}
  20 +
  21 +- (void)setDefaultValues
  22 +{
  23 + _inflexionPointStyle = PNLineChartPointStyleNone;
  24 + _inflexionPointWidth = 6.f;
  25 + _lineWidth = 2.f;
  26 +}
  27 +
10 @end 28 @end
@@ -64,12 +64,14 @@ @@ -64,12 +64,14 @@
64 lineChart.yLabelFormat = @"%1.1f"; 64 lineChart.yLabelFormat = @"%1.1f";
65 lineChart.backgroundColor = [UIColor clearColor]; 65 lineChart.backgroundColor = [UIColor clearColor];
66 [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"]];
  67 + lineChart.showCoordinateAxis = YES;
67 68
68 // Line Chart Nr.1 69 // Line Chart Nr.1
69 NSArray * data01Array = @[@60.1, @160.1, @126.4, @262.2, @186.2, @127.2, @176.2]; 70 NSArray * data01Array = @[@60.1, @160.1, @126.4, @262.2, @186.2, @127.2, @176.2];
70 PNLineChartData *data01 = [PNLineChartData new]; 71 PNLineChartData *data01 = [PNLineChartData new];
71 data01.color = PNFreshGreen; 72 data01.color = PNFreshGreen;
72 data01.itemCount = lineChart.xLabels.count; 73 data01.itemCount = lineChart.xLabels.count;
  74 + data01.inflexionPointStyle = PNLineChartPointStyleCycle;
73 data01.getData = ^(NSUInteger index) { 75 data01.getData = ^(NSUInteger index) {
74 CGFloat yValue = [data01Array[index] floatValue]; 76 CGFloat yValue = [data01Array[index] floatValue];
75 return [PNLineChartDataItem dataItemWithY:yValue]; 77 return [PNLineChartDataItem dataItemWithY:yValue];
@@ -80,6 +82,7 @@ @@ -80,6 +82,7 @@
80 PNLineChartData *data02 = [PNLineChartData new]; 82 PNLineChartData *data02 = [PNLineChartData new];
81 data02.color = PNTwitterColor; 83 data02.color = PNTwitterColor;
82 data02.itemCount = lineChart.xLabels.count; 84 data02.itemCount = lineChart.xLabels.count;
  85 + data02.inflexionPointStyle = PNLineChartPointStyleSquare;
83 data02.getData = ^(NSUInteger index) { 86 data02.getData = ^(NSUInteger index) {
84 CGFloat yValue = [data02Array[index] floatValue]; 87 CGFloat yValue = [data02Array[index] floatValue];
85 return [PNLineChartDataItem dataItemWithY:yValue]; 88 return [PNLineChartDataItem dataItemWithY:yValue];