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
MrWooJ
2014-12-14 18:34:01 +0330
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cd1e0fed6db517ce18aaec983de2b4f309a27c2f
cd1e0fed
1 parent
abcfe3dd
drawing UI methods on the background thread
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
6 deletions
PNChart/PNScatterChart.m
PNChart/PNScatterChart.m
View file @
cd1e0fe
...
...
@@ -181,8 +181,8 @@
-
(
void
)
setChartData
:
(
NSArray
*
)
data
{
if
(
data
!=
_chartData
)
{
CGFloat
yFinilizeValue
,
xFinilizeValue
;
CGFloat
yValue
,
xValue
;
__block
CGFloat
yFinilizeValue
,
xFinilizeValue
;
__block
CGFloat
yValue
,
xValue
;
CABasicAnimation
*
pathAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"opacity"
];
pathAnimation
.
duration
=
_duration
;
pathAnimation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
...
...
@@ -191,6 +191,10 @@
pathAnimation
.
fillMode
=
kCAFillModeForwards
;
self
.
layer
.
opacity
=
1
;
dispatch_async
(
dispatch_get_global_queue
(
DISPATCH_QUEUE_PRIORITY_DEFAULT
,
0
),
^
{
[
NSThread
sleepForTimeInterval
:
1
];
// update UI on the main thread
dispatch_async
(
dispatch_get_main_queue
(),
^
{
for
(
PNScatterChartData
*
chartData
in
data
)
{
for
(
NSUInteger
i
=
0
;
i
<
chartData
.
itemCount
;
i
++
)
{
yValue
=
chartData
.
getData
(
i
).
y
;
...
...
@@ -207,6 +211,8 @@
[
self
.
pathLayer
addAnimation
:
pathAnimation
forKey
:
@"fade"
];
}
}
});
});
}
}
...
...
@@ -313,11 +319,17 @@
}
-
(
void
)
drawLineFromPoint
:
(
CGPoint
)
startPoint
ToPoint
:
(
CGPoint
)
endPoint
WithLineWith
:
(
CGFloat
)
lineWidth
AndWithColor
:
(
UIColor
*
)
color
{
// call the same method on a background thread
dispatch_async
(
dispatch_get_global_queue
(
DISPATCH_QUEUE_PRIORITY_DEFAULT
,
0
),
^
{
[
NSThread
sleepForTimeInterval
:
2
];
// calculating start and end point
CGFloat
startX
=
[
self
mappingIsForAxisX
:
true
WithValue
:
startPoint
.
x
];
CGFloat
startY
=
[
self
mappingIsForAxisX
:
false
WithValue
:
startPoint
.
y
];
CGFloat
endX
=
[
self
mappingIsForAxisX
:
true
WithValue
:
endPoint
.
x
];
CGFloat
endY
=
[
self
mappingIsForAxisX
:
false
WithValue
:
endPoint
.
y
];
__block
CGFloat
startX
=
[
self
mappingIsForAxisX
:
true
WithValue
:
startPoint
.
x
];
__block
CGFloat
startY
=
[
self
mappingIsForAxisX
:
false
WithValue
:
startPoint
.
y
];
__block
CGFloat
endX
=
[
self
mappingIsForAxisX
:
true
WithValue
:
endPoint
.
x
];
__block
CGFloat
endY
=
[
self
mappingIsForAxisX
:
false
WithValue
:
endPoint
.
y
];
// update UI on the main thread
dispatch_async
(
dispatch_get_main_queue
(),
^
{
// drawing path between two points
UIBezierPath
*
path
=
[
UIBezierPath
bezierPath
];
[
path
moveToPoint
:
CGPointMake
(
startX
,
startY
)];
...
...
@@ -334,6 +346,8 @@
animateStrokeEnd
.
toValue
=
[
NSNumber
numberWithFloat
:
1
.
0
f
];
[
shapeLayer
addAnimation
:
animateStrokeEnd
forKey
:
nil
];
[
self
.
layer
addSublayer
:
shapeLayer
];
});
});
}
@end
...
...
Please
register
or
login
to post a comment