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
Karol Magier
2015-07-14 14:38:35 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6d7018762768b0e37728bfc4e2383d717e3881a9
6d701876
1 parent
fa4192a8
Add public BOOL property for sector highlight on touch (pie chart)
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
19 deletions
PNChart/PNPieChart.h
PNChart/PNPieChart.m
PNChart/PNPieChart.h
View file @
6d70187
...
...
@@ -38,6 +38,9 @@
/** Show absolute values not relative i.e. percentages */
@property
(
nonatomic
)
BOOL
showAbsoluteValues
;
/** Default YES. */
@property
(
nonatomic
)
BOOL
shouldHighlightSectorOnTouch
;
@property
(
nonatomic
,
weak
)
id
<
PNChartDelegate
>
delegate
;
-
(
void
)
strokeChart
;
...
...
PNChart/PNPieChart.m
View file @
6d70187
...
...
@@ -56,6 +56,7 @@
_descriptionTextShadowColor
=
[[
UIColor
blackColor
]
colorWithAlphaComponent
:
0
.
4
];
_descriptionTextShadowOffset
=
CGSizeMake
(
0
,
1
);
_duration
=
1
.
0
;
_shouldHighlightSectorOnTouch
=
YES
;
[
super
setupDefaultValues
];
[
self
loadDefault
];
...
...
@@ -277,26 +278,30 @@
[
self
.
delegate
userClickedOnPieIndexItem
:
index
];
}
if
(
self
.
sectorHighlight
)
{
[
self
.
sectorHighlight
removeFromSuperlayer
];
if
(
self
.
shouldHighlightSectorOnTouch
)
{
if
(
self
.
sectorHighlight
)
{
[
self
.
sectorHighlight
removeFromSuperlayer
];
}
PNPieChartDataItem
*
currentItem
=
[
self
dataItemForIndex
:
index
];
CGFloat
red
,
green
,
blue
,
alpha
;
UIColor
*
old
=
currentItem
.
color
;
[
old
getRed
:
&
red
green
:
&
green
blue
:&
blue
alpha
:&
alpha
];
alpha
/=
2
;
UIColor
*
newColor
=
[
UIColor
colorWithRed
:
red
green
:
green
blue
:
blue
alpha
:
alpha
];
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
];
[
_contentView
.
layer
addSublayer
:
self
.
sectorHighlight
];
}
PNPieChartDataItem
*
currentItem
=
[
self
dataItemForIndex
:
index
];
CGFloat
red
,
green
,
blue
,
alpha
;
UIColor
*
old
=
currentItem
.
color
;
[
old
getRed
:
&
red
green
:
&
green
blue
:&
blue
alpha
:&
alpha
];
alpha
/=
2
;
UIColor
*
newColor
=
[
UIColor
colorWithRed
:
red
green
:
green
blue
:
blue
alpha
:
alpha
];
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
];
[
_contentView
.
layer
addSublayer
:
self
.
sectorHighlight
];
}
-
(
void
)
touchesBegan
:
(
NSSet
*
)
touches
withEvent
:
(
UIEvent
*
)
event
...
...
Please
register
or
login
to post a comment