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
Peter Foti
2013-12-10 10:29:22 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ea768f464c7c19c2c5c788b9d4d70ee08f6cede8
ea768f46
1 parent
bf05af2e
Minor formatting changes, and fixed dead store
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
49 deletions
PNChartDemo/PNChart/PNBar.m
PNChartDemo/PNChart/PNBarChart.m
PNChartDemo/PNChart/PNCircleChart.m
PNChartDemo/PNChart/PNLineChart.m
PNChartDemo/PNChart/PNBar.m
View file @
ea768f4
...
...
@@ -16,14 +16,14 @@
self
=
[
super
initWithFrame
:
frame
];
if
(
self
)
{
// Initialization code
_chartLine
=
[
CAShapeLayer
layer
];
_chartLine
.
lineCap
=
kCALineCapButt
;
_chartLine
.
fillColor
=
[[
UIColor
whiteColor
]
CGColor
];
_chartLine
.
lineWidth
=
self
.
frame
.
size
.
width
;
_chartLine
.
strokeEnd
=
0
.
0
;
self
.
clipsToBounds
=
YES
;
_chartLine
=
[
CAShapeLayer
layer
];
_chartLine
.
lineCap
=
kCALineCapButt
;
_chartLine
.
fillColor
=
[[
UIColor
whiteColor
]
CGColor
];
_chartLine
.
lineWidth
=
self
.
frame
.
size
.
width
;
_chartLine
.
strokeEnd
=
0
.
0
;
self
.
clipsToBounds
=
YES
;
[
self
.
layer
addSublayer
:
_chartLine
];
self
.
layer
.
cornerRadius
=
2
.
0
;
self
.
layer
.
cornerRadius
=
2
.
0
;
}
return
self
;
}
...
...
@@ -51,7 +51,6 @@
pathAnimation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
pathAnimation
.
fromValue
=
[
NSNumber
numberWithFloat
:
0
.
0
f
];
pathAnimation
.
toValue
=
[
NSNumber
numberWithFloat
:
1
.
0
f
];
pathAnimation
.
autoreverses
=
NO
;
[
_chartLine
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
_chartLine
.
strokeEnd
=
1
.
0
;
...
...
PNChartDemo/PNChart/PNBarChart.m
View file @
ea768f4
...
...
@@ -19,9 +19,9 @@
if
(
self
)
{
// Initialization code
self
.
backgroundColor
=
[
UIColor
whiteColor
];
self
.
clipsToBounds
=
YES
;
_showLabel
=
YES
;
_barBackgroundColor
=
PNLightGrey
;
self
.
clipsToBounds
=
YES
;
_showLabel
=
YES
;
_barBackgroundColor
=
PNLightGrey
;
}
return
self
;
...
...
@@ -88,7 +88,7 @@
float
value
=
[
valueString
floatValue
];
float
grade
=
(
float
)
value
/
(
float
)
_yValueMax
;
PNBar
*
bar
=
[[
PNBar
alloc
]
init
]
;
PNBar
*
bar
;
if
(
_showLabel
)
{
bar
=
[[
PNBar
alloc
]
initWithFrame
:
CGRectMake
((
index
*
_xLabelWidth
+
chartMargin
+
_xLabelWidth
*
0
.
25
),
self
.
frame
.
size
.
height
-
chartCavanHeight
-
30
.
0
,
_xLabelWidth
*
0
.
5
,
chartCavanHeight
)];
}
else
{
...
...
@@ -99,12 +99,8 @@
bar
.
grade
=
grade
;
[
self
addSubview
:
bar
];
index
+=
1
;
}
}
@end
...
...
PNChartDemo/PNChart/PNCircleChart.m
View file @
ea768f4
...
...
@@ -22,21 +22,21 @@
UIBezierPath
*
circlePath
=
[
UIBezierPath
bezierPathWithArcCenter
:
CGPointMake
(
self
.
center
.
x
,
self
.
center
.
y
)
radius
:
self
.
frame
.
size
.
height
*
0
.
5
startAngle
:
DEGREES_TO_RADIANS
(
270
)
endAngle
:
DEGREES_TO_RADIANS
(
270
.
01
)
clockwise
:
NO
];
_circle
=
[
CAShapeLayer
layer
];
_circle
.
path
=
circlePath
.
CGPath
;
_circle
.
lineCap
=
kCALineCapRound
;
_circle
.
fillColor
=
[
UIColor
clearColor
].
CGColor
;
_circle
.
lineWidth
=
[
_lineWidth
floatValue
];
_circle
.
zPosition
=
1
;
_circleBG
=
[
CAShapeLayer
layer
];
_circleBG
.
path
=
circlePath
.
CGPath
;
_circleBG
.
lineCap
=
kCALineCapRound
;
_circle
=
[
CAShapeLayer
layer
];
_circle
.
path
=
circlePath
.
CGPath
;
_circle
.
lineCap
=
kCALineCapRound
;
_circle
.
fillColor
=
[
UIColor
clearColor
].
CGColor
;
_circle
.
lineWidth
=
[
_lineWidth
floatValue
];
_circle
.
zPosition
=
1
;
_circleBG
=
[
CAShapeLayer
layer
];
_circleBG
.
path
=
circlePath
.
CGPath
;
_circleBG
.
lineCap
=
kCALineCapRound
;
_circleBG
.
fillColor
=
[
UIColor
clearColor
].
CGColor
;
_circleBG
.
lineWidth
=
[
_lineWidth
floatValue
];
_circleBG
.
strokeColor
=
PNLightYellow
.
CGColor
;
_circleBG
.
strokeEnd
=
1
.
0
;
_circleBG
.
zPosition
=
-
1
;
_circleBG
.
zPosition
=
-
1
;
[
self
.
layer
addSublayer
:
_circle
];
[
self
.
layer
addSublayer
:
_circleBG
];
...
...
@@ -51,7 +51,7 @@
{
//Add count label
UICountingLabel
*
gradeLabel
=
[[
UICountingLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
50
.
0
,
50
.
0
)];
UICountingLabel
*
gradeLabel
=
[[
UICountingLabel
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
50
.
0
,
50
.
0
)];
[
gradeLabel
setTextAlignment
:
NSTextAlignmentCenter
];
[
gradeLabel
setFont
:[
UIFont
boldSystemFontOfSize
:
13
.
0
f
]];
[
gradeLabel
setTextColor
:
PNDeepGrey
];
...
...
@@ -65,8 +65,8 @@
//Add circle params
_circle
.
lineWidth
=
[
_lineWidth
floatValue
];
_circleBG
.
lineWidth
=
[
_lineWidth
floatValue
];
_circleBG
.
strokeEnd
=
1
.
0
;
_circleBG
.
lineWidth
=
[
_lineWidth
floatValue
];
_circleBG
.
strokeEnd
=
1
.
0
;
_circle
.
strokeColor
=
_strokeColor
.
CGColor
;
//Add Animation
...
...
@@ -75,7 +75,6 @@
pathAnimation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
pathAnimation
.
fromValue
=
[
NSNumber
numberWithFloat
:
0
.
0
f
];
pathAnimation
.
toValue
=
[
NSNumber
numberWithFloat
:[
_current
floatValue
]
/
[
_total
floatValue
]];
pathAnimation
.
autoreverses
=
NO
;
[
_circle
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
_circle
.
strokeEnd
=
[
_current
floatValue
]
/
[
_total
floatValue
];
...
...
@@ -83,13 +82,4 @@
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end
...
...
PNChartDemo/PNChart/PNLineChart.m
View file @
ea768f4
...
...
@@ -18,14 +18,14 @@
if
(
self
)
{
// Initialization code
self
.
backgroundColor
=
[
UIColor
whiteColor
];
self
.
clipsToBounds
=
YES
;
_chartLine
=
[
CAShapeLayer
layer
];
_chartLine
.
lineCap
=
kCALineCapRound
;
_chartLine
.
lineJoin
=
kCALineJoinBevel
;
_chartLine
.
fillColor
=
[[
UIColor
whiteColor
]
CGColor
];
_chartLine
.
lineWidth
=
3
.
0
;
_chartLine
.
strokeEnd
=
0
.
0
;
_showLabel
=
YES
;
self
.
clipsToBounds
=
YES
;
_chartLine
=
[
CAShapeLayer
layer
];
_chartLine
.
lineCap
=
kCALineCapRound
;
_chartLine
.
lineJoin
=
kCALineJoinBevel
;
_chartLine
.
fillColor
=
[[
UIColor
whiteColor
]
CGColor
];
_chartLine
.
lineWidth
=
3
.
0
;
_chartLine
.
strokeEnd
=
0
.
0
;
_showLabel
=
YES
;
[
self
.
layer
addSublayer
:
_chartLine
];
}
...
...
@@ -157,7 +157,6 @@
pathAnimation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
pathAnimation
.
fromValue
=
[
NSNumber
numberWithFloat
:
0
.
0
f
];
pathAnimation
.
toValue
=
[
NSNumber
numberWithFloat
:
1
.
0
f
];
pathAnimation
.
autoreverses
=
NO
;
[
_chartLine
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
_chartLine
.
strokeEnd
=
1
.
0
;
...
...
Please
register
or
login
to post a comment