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
Emma Makinson
2015-12-18 12:05:27 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
Edu Caselles
2015-12-18 13:26:18 +0100
Commit
315033e02c534eb2685a65fc7f1b535c954c65db
315033e0
1 parent
7a60702d
Makes animation optional on Line Chart
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
9 deletions
PNChart/PNLineChart.h
PNChart/PNLineChart.m
PNChart/PNLineChart.h
View file @
315033e
...
...
@@ -74,6 +74,9 @@
*/
@property
(
nonatomic
,
copy
)
NSString
*
(
^
yLabelBlockFormatter
)(
CGFloat
);
/** Display the line chart with or without animation. Default is YES. **/
@property
(
nonatomic
)
BOOL
displayAnimated
;
-
(
void
)
setXLabels
:(
NSArray
*
)
xLabels
withWidth
:(
CGFloat
)
width
;
/**
...
...
PNChart/PNLineChart.m
View file @
315033e
...
...
@@ -22,6 +22,8 @@
@property
(
nonatomic
)
NSMutableArray
*
pointPath
;
// Array of point path, one for each line
@property
(
nonatomic
)
NSMutableArray
*
endPointsOfPath
;
// Array of start and end points of each line path, one for each line
@property
(
nonatomic
)
CABasicAnimation
*
pathAnimation
;
// will be set to nil if _displayAnimation is NO
// display grade
@property
(
nonatomic
)
NSMutableArray
*
gradeStringPaths
;
...
...
@@ -29,6 +31,8 @@
@implementation
PNLineChart
@synthesize
pathAnimation
=
_pathAnimation
;
#pragma mark initialization
-
(
id
)
initWithCoder
:(
NSCoder
*
)
coder
...
...
@@ -340,18 +344,13 @@
pointLayer
.
path
=
pointPath
.
CGPath
;
[
CATransaction
begin
];
CABasicAnimation
*
pathAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"strokeEnd"
];
pathAnimation
.
duration
=
1
.
0
;
pathAnimation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
pathAnimation
.
fromValue
=
@0.0f
;
pathAnimation
.
toValue
=
@1.0f
;
[
chartLine
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
[
chartLine
addAnimation
:
self
.
pathAnimation
forKey
:
@"strokeEndAnimation"
];
chartLine
.
strokeEnd
=
1
.
0
;
// if you want cancel the point animation, conment this code, the point will show immediately
if
(
chartData
.
inflexionPointStyle
!=
PNLineChartPointStyleNone
)
{
[
pointLayer
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
[
pointLayer
addAnimation
:
self
.
pathAnimation
forKey
:
@"strokeEndAnimation"
];
}
[
CATransaction
commit
];
...
...
@@ -754,8 +753,9 @@
self
.
backgroundColor
=
[
UIColor
whiteColor
];
self
.
clipsToBounds
=
YES
;
self
.
chartLineArray
=
[
NSMutableArray
new
];
_showLabel
=
YES
;
_showGenYLabels
=
YES
;
_showLabel
=
YES
;
_showGenYLabels
=
YES
;
_displayAnimated
=
YES
;
_pathPoints
=
[[
NSMutableArray
alloc
]
init
];
_endPointsOfPath
=
[[
NSMutableArray
alloc
]
init
];
self
.
userInteractionEnabled
=
YES
;
...
...
@@ -1052,4 +1052,16 @@
return
fadeAnimation
;
}
-
(
CABasicAnimation
*
)
pathAnimation
{
if
(
_displayAnimated
&&
!
_pathAnimation
)
{
_pathAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"strokeEnd"
];
_pathAnimation
.
duration
=
1
.
0
;
_pathAnimation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
_pathAnimation
.
fromValue
=
@0.0f
;
_pathAnimation
.
toValue
=
@1.0f
;
}
return
_pathAnimation
;
}
@end
...
...
Please
register
or
login
to post a comment