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
Kevin
2014-05-29 14:37:16 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
6191c71d3dceb84533c86f0d12545f9e3ac1baa8
6191c71d
2 parents
5a6caa51
32bd04c6
Merge pull request #63 from jackyzonewen/master
Add axis separator
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
10 deletions
PNChart/PNLineChart/PNLineChart.m
PNChart/PNLineChart/PNLineChart.m
View file @
6191c71
...
...
@@ -331,7 +331,8 @@
[
chartLine
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
chartLine
.
strokeEnd
=
1
.
0
;
if
(
chartData
.
inflexionPointStyle
==
PNLineChartPointStyleCycle
)
{
// if you want cancel the point animation, conment this code, the point will show immediately
if
(
chartData
.
inflexionPointStyle
!=
PNLineChartPointStyleNone
)
{
[
pointLayer
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
}
...
...
@@ -424,28 +425,54 @@
{
if
(
self
.
isShowCoordinateAxis
)
{
CGFloat
yAsixOffset
=
10
.
f
;
CGContextRef
ctx
=
UIGraphicsGetCurrentContext
();
UIGraphicsPushContext
(
ctx
);
CGContextSetLineWidth
(
ctx
,
self
.
axisWidth
);
CGContextSetStrokeColorWithColor
(
ctx
,
[
self
.
axisColor
CGColor
]);
CGFloat
xAxisWidth
=
CGRectGetWidth
(
rect
)
-
_chartMargin
/
2
;
CGFloat
yAxisHeight
=
_chartMargin
+
_chartCavanHeight
;
// draw coordinate axis
CGContextMoveToPoint
(
ctx
,
_chartMargin
+
10
,
0
);
CGContextAddLineToPoint
(
ctx
,
_chartMargin
+
10
,
_chartMargin
+
_chartCavan
Height
);
CGContextAddLineToPoint
(
ctx
,
CGRectGetWidth
(
rect
)
-
_chartMargin
,
_chartMargin
+
_chartCavan
Height
);
CGContextMoveToPoint
(
ctx
,
_chartMargin
+
yAsixOffset
,
0
);
CGContextAddLineToPoint
(
ctx
,
_chartMargin
+
yAsixOffset
,
yAxis
Height
);
CGContextAddLineToPoint
(
ctx
,
xAxisWidth
,
yAxis
Height
);
CGContextStrokePath
(
ctx
);
// draw y axis arrow
CGContextMoveToPoint
(
ctx
,
_chartMargin
+
6
,
8
);
CGContextAddLineToPoint
(
ctx
,
_chartMargin
+
10
,
0
);
CGContextAddLineToPoint
(
ctx
,
_chartMargin
+
14
,
8
);
CGContextMoveToPoint
(
ctx
,
_chartMargin
+
yAsixOffset
-
3
,
6
);
CGContextAddLineToPoint
(
ctx
,
_chartMargin
+
yAsixOffset
,
0
);
CGContextAddLineToPoint
(
ctx
,
_chartMargin
+
yAsixOffset
+
3
,
6
);
CGContextStrokePath
(
ctx
);
// draw x axis arrow
CGContextMoveToPoint
(
ctx
,
CGRectGetWidth
(
rect
)
-
_chartMargin
-
8
,
_chartMargin
+
_chartCavanHeight
-
4
);
CGContextAddLineToPoint
(
ctx
,
CGRectGetWidth
(
rect
)
-
_chartMargin
,
_chartMargin
+
_chartCavanHeight
);
CGContextAddLineToPoint
(
ctx
,
CGRectGetWidth
(
rect
)
-
_chartMargin
-
8
,
_chartMargin
+
_chartCavanHeight
+
4
);
CGContextMoveToPoint
(
ctx
,
xAxisWidth
-
6
,
yAxisHeight
-
3
);
CGContextAddLineToPoint
(
ctx
,
xAxisWidth
,
yAxisHeight
);
CGContextAddLineToPoint
(
ctx
,
xAxisWidth
-
6
,
yAxisHeight
+
3
);
CGContextStrokePath
(
ctx
);
if
(
self
.
showLabel
)
{
// draw x axis separator
CGPoint
point
;
for
(
NSUInteger
i
=
0
;
i
<
[
self
.
xLabels
count
];
i
++
)
{
point
=
CGPointMake
(
2
*
_chartMargin
+
(
i
*
_xLabelWidth
),
_chartMargin
+
_chartCavanHeight
);
CGContextMoveToPoint
(
ctx
,
point
.
x
,
point
.
y
-
2
);
CGContextAddLineToPoint
(
ctx
,
point
.
x
,
point
.
y
);
CGContextStrokePath
(
ctx
);
}
// draw y axis separator
CGFloat
yStepHeight
=
_chartCavanHeight
/
_yLabelNum
;
for
(
NSUInteger
i
=
0
;
i
<
[
self
.
xLabels
count
];
i
++
)
{
point
=
CGPointMake
(
_chartMargin
+
yAsixOffset
,
(
_chartCavanHeight
-
i
*
yStepHeight
+
_yLabelHeight
/
2
));
CGContextMoveToPoint
(
ctx
,
point
.
x
,
point
.
y
);
CGContextAddLineToPoint
(
ctx
,
point
.
x
+
2
,
point
.
y
);
CGContextStrokePath
(
ctx
);
}
}
UIFont
*
font
=
[
UIFont
systemFontOfSize
:
11
];
// draw y unit
...
...
Please
register
or
login
to post a comment