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];
... ... @@ -290,9 +296,11 @@
[self.delegate userClickedOnPieIndexItem:index];
}
if (self.shouldHighlightSectorOnTouch) {
if (self.sectorHighlight) {
if (self.shouldHighlightSectorOnTouch)
{
if (!self.enableMultipleSelection)
{
if (self.sectorHighlight)
[self.sectorHighlight removeFromSuperlayer];
}
... ... @@ -306,14 +314,34 @@
CGFloat startPercnetage = [self startPercentageForItemAtIndex:index];
CGFloat endPercentage = [self endPercentageForItemAtIndex:index];
self.sectorHighlight = [self newCircleLayerWithRadius:_outerCircleRadius + 5
borderWidth:10
fillColor:[UIColor clearColor]
borderColor:newColor
startPercentage:startPercnetage
endPercentage:endPercentage];
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];
}
}
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
... ...
<?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>
... ...
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7531" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="9Rt-UT-IxH">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="9Rt-UT-IxH">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<scenes>
<!--PNChart-->
... ... @@ -29,7 +29,7 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FUU-vZ-jMd">
<rect key="frame" x="53" y="81" width="215" height="30"/>
<fontDescription key="fontDescription" name="Avenir-Medium" family="Avenir" pointSize="23"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ORA-mb-hJl">
... ... @@ -38,7 +38,7 @@
<action selector="leftSwitchChanged:" destination="Tha-Wr-sPW" eventType="valueChanged" id="q9T-QK-Sas"/>
</connections>
</switch>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qR7-40-7ir">
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qR7-40-7ir">
<rect key="frame" x="261" y="489" width="51" height="31"/>
<connections>
<action selector="rightSwitchChanged:" destination="Tha-Wr-sPW" eventType="valueChanged" id="n6V-lL-r8Q"/>
... ... @@ -47,26 +47,43 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Percentage" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IKu-qh-ksi">
<rect key="frame" x="16" y="528" width="121" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Show Labels" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ifm-a9-Wkq">
<rect key="frame" x="192" y="527" width="118" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="kav-3r-blI">
<rect key="frame" x="142" y="461" width="51" height="31"/>
<connections>
<action selector="centerSwitchChanged:" destination="Tha-Wr-sPW" eventType="valueChanged" id="ETI-hb-d8F"/>
<action selector="rightSwitchChanged:" destination="Tha-Wr-sPW" eventType="valueChanged" id="2Rs-PH-2WM"/>
</connections>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" misplaced="YES" text="Multiple Selection" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sMF-o9-dZX">
<rect key="frame" x="73" y="499" width="137" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="qR7-40-7ir" firstAttribute="top" secondItem="kav-3r-blI" secondAttribute="bottom" constant="10" id="4Qo-Xx-bbF"/>
<constraint firstItem="FUU-vZ-jMd" firstAttribute="top" secondItem="znr-YO-4a4" secondAttribute="bottom" constant="17" id="DLv-qJ-h7R"/>
<constraint firstAttribute="centerX" secondItem="FUU-vZ-jMd" secondAttribute="centerX" id="YGT-a5-Zka"/>
<constraint firstItem="kav-3r-blI" firstAttribute="centerX" secondItem="sMF-o9-dZX" secondAttribute="centerX" id="aUL-sS-9ZE"/>
<constraint firstAttribute="centerX" secondItem="kav-3r-blI" secondAttribute="centerX" id="aap-Gv-rtz"/>
<constraint firstItem="L3F-13-Wf5" firstAttribute="top" secondItem="znr-YO-4a4" secondAttribute="bottom" constant="300" id="ewm-kv-p8k"/>
<constraint firstAttribute="centerX" secondItem="L3F-13-Wf5" secondAttribute="centerX" id="zXw-WV-mro"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="PNChart" id="Ukg-Sg-E2z"/>
<connections>
<outlet property="centerSwitch" destination="kav-3r-blI" id="aDA-mR-FhR"/>
<outlet property="changeValueButton" destination="L3F-13-Wf5" id="JnI-y3-Xpj"/>
<outlet property="leftLabel" destination="IKu-qh-ksi" id="CPy-oy-qCP"/>
<outlet property="leftSwitch" destination="ORA-mb-hJl" id="u1M-2f-6P1"/>
... ... @@ -101,7 +118,7 @@
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
... ... @@ -121,7 +138,7 @@
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
... ... @@ -141,7 +158,7 @@
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
... ... @@ -161,7 +178,7 @@
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
... ... @@ -179,7 +196,7 @@
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="ScatterChart" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="YOU-SK-mQU">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
... ... @@ -199,7 +216,7 @@
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
... ...
... ... @@ -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
... ...