Showing
1 changed file
with
15 additions
and
2 deletions
| @@ -11,7 +11,11 @@ | @@ -11,7 +11,11 @@ | ||
| 11 | #import "PNChartLabel.h" | 11 | #import "PNChartLabel.h" |
| 12 | #import "PNBar.h" | 12 | #import "PNBar.h" |
| 13 | 13 | ||
| 14 | -@interface PNBarChart() | 14 | +@interface PNBarChart() { |
| 15 | + NSMutableArray* _bars; | ||
| 16 | + NSMutableArray* _labels; | ||
| 17 | +} | ||
| 18 | + | ||
| 15 | - (UIColor *)barColorAtIndex:(NSUInteger)index; | 19 | - (UIColor *)barColorAtIndex:(NSUInteger)index; |
| 16 | @end | 20 | @end |
| 17 | 21 | ||
| @@ -62,6 +66,7 @@ | @@ -62,6 +66,7 @@ | ||
| 62 | 66 | ||
| 63 | -(void)setXLabels:(NSArray *)xLabels | 67 | -(void)setXLabels:(NSArray *)xLabels |
| 64 | { | 68 | { |
| 69 | + [self viewCleanupForCollection:_labels]; | ||
| 65 | _xLabels = xLabels; | 70 | _xLabels = xLabels; |
| 66 | 71 | ||
| 67 | if (_showLabel) { | 72 | if (_showLabel) { |
| @@ -86,7 +91,7 @@ | @@ -86,7 +91,7 @@ | ||
| 86 | 91 | ||
| 87 | -(void)strokeChart | 92 | -(void)strokeChart |
| 88 | { | 93 | { |
| 89 | - | 94 | + [self viewCleanupForCollection:_bars]; |
| 90 | CGFloat chartCavanHeight = self.frame.size.height - chartMargin * 2 - 40.0; | 95 | CGFloat chartCavanHeight = self.frame.size.height - chartMargin * 2 - 40.0; |
| 91 | NSInteger index = 0; | 96 | NSInteger index = 0; |
| 92 | 97 | ||
| @@ -109,6 +114,14 @@ | @@ -109,6 +114,14 @@ | ||
| 109 | } | 114 | } |
| 110 | } | 115 | } |
| 111 | 116 | ||
| 117 | +- (void)viewCleanupForCollection:(NSMutableArray*)array | ||
| 118 | +{ | ||
| 119 | + if (array.count) { | ||
| 120 | + [array makeObjectsPerformSelector:@selector(removeFromSuperview)]; | ||
| 121 | + [array removeAllObjects]; | ||
| 122 | + } | ||
| 123 | +} | ||
| 124 | + | ||
| 112 | #pragma mark - Class extension methods | 125 | #pragma mark - Class extension methods |
| 113 | 126 | ||
| 114 | - (UIColor *)barColorAtIndex:(NSUInteger)index | 127 | - (UIColor *)barColorAtIndex:(NSUInteger)index |
-
Please register or login to post a comment