Showing
3 changed files
with
13 additions
and
3 deletions
| @@ -28,6 +28,7 @@ | @@ -28,6 +28,7 @@ | ||
| 28 | @property (nonatomic) NSArray *chartData; | 28 | @property (nonatomic) NSArray *chartData; |
| 29 | 29 | ||
| 30 | @property (nonatomic) NSMutableArray *pathPoints; | 30 | @property (nonatomic) NSMutableArray *pathPoints; |
| 31 | +@property (nonatomic) NSMutableArray *xChartLabels; | ||
| 31 | @property (nonatomic) CGFloat xLabelWidth; | 32 | @property (nonatomic) CGFloat xLabelWidth; |
| 32 | @property (nonatomic) UIFont *xLabelFont; | 33 | @property (nonatomic) UIFont *xLabelFont; |
| 33 | @property (nonatomic) UIColor *xLabelColor; | 34 | @property (nonatomic) UIColor *xLabelColor; |
| @@ -108,7 +108,14 @@ | @@ -108,7 +108,14 @@ | ||
| 108 | { | 108 | { |
| 109 | _xLabels = xLabels; | 109 | _xLabels = xLabels; |
| 110 | _xLabelWidth = width; | 110 | _xLabelWidth = width; |
| 111 | - | 111 | + if (_xChartLabels) { |
| 112 | + for (PNChartLabel * label in _xChartLabels) { | ||
| 113 | + [label removeFromSuperview]; | ||
| 114 | + } | ||
| 115 | + }else{ | ||
| 116 | + _xChartLabels = [NSMutableArray new]; | ||
| 117 | + } | ||
| 118 | + | ||
| 112 | NSString *labelText; | 119 | NSString *labelText; |
| 113 | 120 | ||
| 114 | if (_showLabel) { | 121 | if (_showLabel) { |
| @@ -123,6 +130,7 @@ | @@ -123,6 +130,7 @@ | ||
| 123 | label.text = labelText; | 130 | label.text = labelText; |
| 124 | [self setCustomStyleForXLabel:label]; | 131 | [self setCustomStyleForXLabel:label]; |
| 125 | [self addSubview:label]; | 132 | [self addSubview:label]; |
| 133 | + [_xChartLabels addObject:label]; | ||
| 126 | } | 134 | } |
| 127 | } | 135 | } |
| 128 | } | 136 | } |
| @@ -75,7 +75,7 @@ | @@ -75,7 +75,7 @@ | ||
| 75 | 75 | ||
| 76 | 76 | ||
| 77 | // Line Chart #1 | 77 | // Line Chart #1 |
| 78 | - NSArray * data01Array = @[@30.1, @220.1, @106.4, @22.2, @136.2, @67.2, @36.2]; | 78 | + NSArray * data01Array = @[@(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300)]; |
| 79 | PNLineChartData *data01 = [PNLineChartData new]; | 79 | PNLineChartData *data01 = [PNLineChartData new]; |
| 80 | data01.color = PNFreshGreen; | 80 | data01.color = PNFreshGreen; |
| 81 | data01.itemCount = data01Array.count; | 81 | data01.itemCount = data01Array.count; |
| @@ -86,7 +86,7 @@ | @@ -86,7 +86,7 @@ | ||
| 86 | }; | 86 | }; |
| 87 | 87 | ||
| 88 | // Line Chart #2 | 88 | // Line Chart #2 |
| 89 | - NSArray * data02Array = @[@60.1, @120.1, @126.4, @102.2, @56.2, @87.2, @136.2]; | 89 | + NSArray * data02Array = @[@(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300), @(arc4random() % 300)]; |
| 90 | PNLineChartData *data02 = [PNLineChartData new]; | 90 | PNLineChartData *data02 = [PNLineChartData new]; |
| 91 | data02.color = PNTwitterColor; | 91 | data02.color = PNTwitterColor; |
| 92 | data02.itemCount = data02Array.count; | 92 | data02.itemCount = data02Array.count; |
| @@ -96,6 +96,7 @@ | @@ -96,6 +96,7 @@ | ||
| 96 | return [PNLineChartDataItem dataItemWithY:yValue]; | 96 | return [PNLineChartDataItem dataItemWithY:yValue]; |
| 97 | }; | 97 | }; |
| 98 | 98 | ||
| 99 | + [self.lineChart setXLabels:@[@"DEC 1",@"DEC 2",@"DEC 3",@"DEC 4",@"DEC 5",@"DEC 6",@"DEC 7"]]; | ||
| 99 | [self.lineChart updateChartData:@[data01, data02]]; | 100 | [self.lineChart updateChartData:@[data01, data02]]; |
| 100 | 101 | ||
| 101 | } | 102 | } |
-
Please register or login to post a comment