Add public BOOL property for sector highlight on touch (pie chart)
Showing
2 changed files
with
8 additions
and
0 deletions
| @@ -38,6 +38,9 @@ | @@ -38,6 +38,9 @@ | ||
| 38 | /** Show absolute values not relative i.e. percentages */ | 38 | /** Show absolute values not relative i.e. percentages */ |
| 39 | @property (nonatomic) BOOL showAbsoluteValues; | 39 | @property (nonatomic) BOOL showAbsoluteValues; |
| 40 | 40 | ||
| 41 | +/** Default YES. */ | ||
| 42 | +@property (nonatomic) BOOL shouldHighlightSectorOnTouch; | ||
| 43 | + | ||
| 41 | @property (nonatomic, weak) id<PNChartDelegate> delegate; | 44 | @property (nonatomic, weak) id<PNChartDelegate> delegate; |
| 42 | 45 | ||
| 43 | - (void)strokeChart; | 46 | - (void)strokeChart; |
| @@ -56,6 +56,7 @@ | @@ -56,6 +56,7 @@ | ||
| 56 | _descriptionTextShadowColor = [[UIColor blackColor] colorWithAlphaComponent:0.4]; | 56 | _descriptionTextShadowColor = [[UIColor blackColor] colorWithAlphaComponent:0.4]; |
| 57 | _descriptionTextShadowOffset = CGSizeMake(0, 1); | 57 | _descriptionTextShadowOffset = CGSizeMake(0, 1); |
| 58 | _duration = 1.0; | 58 | _duration = 1.0; |
| 59 | + _shouldHighlightSectorOnTouch = YES; | ||
| 59 | 60 | ||
| 60 | [super setupDefaultValues]; | 61 | [super setupDefaultValues]; |
| 61 | [self loadDefault]; | 62 | [self loadDefault]; |
| @@ -277,9 +278,12 @@ | @@ -277,9 +278,12 @@ | ||
| 277 | [self.delegate userClickedOnPieIndexItem:index]; | 278 | [self.delegate userClickedOnPieIndexItem:index]; |
| 278 | } | 279 | } |
| 279 | 280 | ||
| 281 | + if (self.shouldHighlightSectorOnTouch) { | ||
| 282 | + | ||
| 280 | if (self.sectorHighlight) { | 283 | if (self.sectorHighlight) { |
| 281 | [self.sectorHighlight removeFromSuperlayer]; | 284 | [self.sectorHighlight removeFromSuperlayer]; |
| 282 | } | 285 | } |
| 286 | + | ||
| 283 | PNPieChartDataItem *currentItem = [self dataItemForIndex:index]; | 287 | PNPieChartDataItem *currentItem = [self dataItemForIndex:index]; |
| 284 | 288 | ||
| 285 | CGFloat red,green,blue,alpha; | 289 | CGFloat red,green,blue,alpha; |
| @@ -297,6 +301,7 @@ | @@ -297,6 +301,7 @@ | ||
| 297 | startPercentage:startPercnetage | 301 | startPercentage:startPercnetage |
| 298 | endPercentage:endPercentage]; | 302 | endPercentage:endPercentage]; |
| 299 | [_contentView.layer addSublayer:self.sectorHighlight]; | 303 | [_contentView.layer addSublayer:self.sectorHighlight]; |
| 304 | + } | ||
| 300 | } | 305 | } |
| 301 | 306 | ||
| 302 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event | 307 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event |
-
Please register or login to post a comment