kevinzhow

Merge branch 'jerrygdm-multiple-selection'

... ... @@ -55,6 +55,9 @@
/** Update chart items. Does not update chart itself. */
- (void)updateChartData:(NSArray *)data;
/** Multiple selection */
@property (nonatomic, assign) BOOL enableMultipleSelection;
- (void)strokeChart;
- (void)recompute;
... ...
... ... @@ -20,6 +20,8 @@
@property (nonatomic) NSMutableArray *descriptionLabels;
@property (strong, nonatomic) CAShapeLayer *sectorHighlight;
@property (nonatomic, strong) NSMutableDictionary *selectedItems;
- (void)loadDefault;
- (UILabel *)descriptionLabelForItemAtIndex:(NSUInteger)index;
... ... @@ -45,12 +47,16 @@
self = [self initWithFrame:frame];
if(self){
_items = [NSArray arrayWithArray:items];
_selectedItems = [NSMutableDictionary dictionary];
_outerCircleRadius = CGRectGetWidth(self.bounds) / 2;
_innerCircleRadius = CGRectGetWidth(self.bounds) / 6;
_descriptionTextColor = [UIColor whiteColor];
_descriptionTextFont = [UIFont fontWithName:@"Avenir-Medium" size:18.0];
_descriptionTextShadowColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
_descriptionTextShadowOffset = CGSizeMake(0, 1);
_duration = 1.0;
_shouldHighlightSectorOnTouch = YES;
_enableMultipleSelection = NO;
[super setupDefaultValues];
[self loadDefault];
... ... @@ -285,15 +291,17 @@
while (percentage > [self endPercentageForItemAtIndex:index]) {
index ++;
}
if ([self.delegate respondsToSelector:@selector(userClickedOnPieIndexItem:)]) {
[self.delegate userClickedOnPieIndexItem:index];
}
if (self.shouldHighlightSectorOnTouch) {
if (self.sectorHighlight) {
[self.sectorHighlight removeFromSuperlayer];
if (self.shouldHighlightSectorOnTouch)
{
if (!self.enableMultipleSelection)
{
if (self.sectorHighlight)
[self.sectorHighlight removeFromSuperlayer];
}
PNPieChartDataItem *currentItem = [self dataItemForIndex:index];
... ... @@ -306,13 +314,33 @@
CGFloat startPercnetage = [self startPercentageForItemAtIndex:index];
CGFloat endPercentage = [self endPercentageForItemAtIndex:index];
self.sectorHighlight = [self newCircleLayerWithRadius:_outerCircleRadius + 5
self.sectorHighlight = [self newCircleLayerWithRadius:_outerCircleRadius + 5
borderWidth:10
fillColor:[UIColor clearColor]
borderColor:newColor
startPercentage:startPercnetage
endPercentage:endPercentage];
[_contentView.layer addSublayer:self.sectorHighlight];
if (self.enableMultipleSelection)
{
NSString *dictIndex = [NSString stringWithFormat:@"%d", index];
CAShapeLayer *indexShape = [self.selectedItems valueForKey:dictIndex];
if (indexShape)
{
[indexShape removeFromSuperlayer];
[self.selectedItems removeObjectForKey:dictIndex];
}
else
{
[self.selectedItems setObject:self.sectorHighlight forKey:dictIndex];
[_contentView.layer addSublayer:self.sectorHighlight];
}
}
else
{
[_contentView.layer addSublayer:self.sectorHighlight];
}
}
}
... ... @@ -403,7 +431,7 @@
x += self.legendStyle == PNLegendItemStyleStacked ? 0 : labelsize.width + beforeLabel;
y += self.legendStyle == PNLegendItemStyleStacked ? labelsize.height : 0;
totalHeight = self.legendStyle == PNLegendItemStyleSerial ? fmaxf(totalHeight, rowMaxHeight + y) : totalHeight + labelsize.height;
[legendViews addObject:label];
counter ++;
... ... @@ -428,7 +456,7 @@
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextAddArc(context, size/2, size/ 2, size/2, 0, M_PI*2, YES);
//Set some fill color
CGContextSetFillColorWithColor(context, color.CGColor);
... ...
<?xml version='1.0' encoding='UTF-8'?><Workspace version='1.0'><FileRef location='group:PNChartDemo.xcodeproj'/><FileRef location='group:Pods/Pods.xcodeproj'/></Workspace>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:PNChartDemo.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
... ...
This diff is collapsed. Click to expand it.
... ... @@ -25,12 +25,13 @@
@property (weak, nonatomic) IBOutlet UIButton *changeValueButton;
@property (weak, nonatomic) IBOutlet UISwitch *leftSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *centerSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *rightSwitch;
@property (weak, nonatomic) IBOutlet UILabel *leftLabel;
@property (weak, nonatomic) IBOutlet UILabel *rightLabel;
- (IBAction)rightSwitchChanged:(id)sender;
- (IBAction)leftSwitchChanged:(id)sender;
- (IBAction)rightSwitchChanged:(id)sender;
@end
... ...
... ... @@ -344,6 +344,15 @@
}
}
- (IBAction)centerSwitchChanged:(id)sender
{
if (self.pieChart)
{
[self.pieChart setEnableMultipleSelection:self.centerSwitch.on];
[self.pieChart strokeChart];
}
}
- (IBAction)leftSwitchChanged:(id)sender {
if ([self.title isEqualToString:@"Pie Chart"]){
UISwitch *showRelative = (UISwitch*) sender;
... ...
PODS:
- Expecta (0.4.2)
- Expecta (1.0.2)
- UICountingLabel (1.2.0)
DEPENDENCIES:
... ... @@ -7,7 +7,7 @@ DEPENDENCIES:
- UICountingLabel (~> 1.2.0)
SPEC CHECKSUMS:
Expecta: 78b4e8b0c8291fa4524d7f74016b6065c2e391ec
Expecta: 54e8a3530add08f4f0208c111355eda7cde74a53
UICountingLabel: 1db4e7d023e1762171eb226d6dff47a7a84f27aa
COCOAPODS: 0.38.2
COCOAPODS: 0.35.0
... ...