Toggle navigation
Toggle navigation
This project
Loading...
Sign in
iOS
/
PNChart
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Gianmaria Dal Maistro
2015-08-20 14:14:05 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d2167db59dca7b6c24933f6d6e898ff7783a056c
d2167db5
1 parent
b5cb75f7
added feature: multiple selection on chart view
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
3 deletions
PNChart/PNPieChart.h
PNChart/PNPieChart.m
PNChart/PNPieChart.h
View file @
d2167db
...
...
@@ -46,6 +46,9 @@
@property
(
nonatomic
,
weak
)
id
<
PNChartDelegate
>
delegate
;
/** Multiple selection */
@property
(
nonatomic
,
assign
)
BOOL
enableMultipleSelection
;
-
(
void
)
strokeChart
;
@end
...
...
PNChart/PNPieChart.m
View file @
d2167db
...
...
@@ -23,6 +23,8 @@
@property
(
nonatomic
)
NSMutableArray
*
descriptionLabels
;
@property
(
strong
,
nonatomic
)
CAShapeLayer
*
sectorHighlight
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
selectedItems
;
-
(
void
)
loadDefault
;
-
(
UILabel
*
)
descriptionLabelForItemAtIndex
:(
NSUInteger
)
index
;
...
...
@@ -48,6 +50,7 @@
self
=
[
self
initWithFrame
:
frame
];
if
(
self
){
_items
=
[
NSArray
arrayWithArray
:
items
];
_selectedItems
=
[
NSMutableDictionary
dictionary
];
_outerCircleRadius
=
CGRectGetWidth
(
self
.
bounds
)
/
2
;
_innerCircleRadius
=
CGRectGetWidth
(
self
.
bounds
)
/
6
;
...
...
@@ -57,6 +60,7 @@
_descriptionTextShadowOffset
=
CGSizeMake
(
0
,
1
);
_duration
=
1
.
0
;
_shouldHighlightSectorOnTouch
=
YES
;
_enableMultipleSelection
=
NO
;
[
super
setupDefaultValues
];
[
self
loadDefault
];
...
...
@@ -284,9 +288,11 @@
[
self
.
delegate
userClickedOnPieIndexItem
:
index
];
}
if
(
self
.
shouldHighlightSectorOnTouch
)
{
if
(
self
.
sectorHighlight
)
{
if
(
self
.
shouldHighlightSectorOnTouch
)
{
if
(
!
self
.
enableMultipleSelection
)
{
if
(
self
.
sectorHighlight
)
[
self
.
sectorHighlight
removeFromSuperlayer
];
}
...
...
@@ -300,14 +306,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
...
...
Please
register
or
login
to post a comment