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
dullgrass
2015-05-29 16:00:19 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
98869cd530c119bd9b5d0ff72c8b8acaed41ed44
98869cd5
1 parent
919d5aeb
delete the relationship between gradient and show numbers
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
9 deletions
PNChart/PNBar.h
PNChart/PNBar.m
PNChart/PNBarChart.h
PNChart/PNBarChart.m
PNChartDemo/PCChartViewController.m
PNChart/PNBar.h
View file @
98869cd
...
...
@@ -27,5 +27,5 @@
@property
(
nonatomic
)
CATextLayer
*
textLayer
;
@property
(
nonatomic
,
assign
)
BOOL
isNegative
;
//!< 是否是负数
@property
(
nonatomic
,
assign
)
BOOL
isShowNumber
;
//!< 是否显示numbers
@end
...
...
PNChart/PNBar.m
View file @
98869cd
...
...
@@ -10,6 +10,12 @@
#import "PNColor.h"
#import <CoreText/CoreText.h>
@interface
PNBar
()
@property
(
nonatomic
)
float
copyGrade
;
@end
@implementation
PNBar
-
(
id
)
initWithFrame
:(
CGRect
)
frame
...
...
@@ -40,7 +46,7 @@
-
(
void
)
setGrade
:(
float
)
grade
{
NSLog
(
@"New garde %f"
,
grade
);
_
g
rade
=
grade
;
_
copyG
rade
=
grade
;
CGFloat
startPosY
=
(
1
-
grade
)
*
self
.
frame
.
size
.
height
;
UIBezierPath
*
progressline
=
[
UIBezierPath
bezierPath
];
...
...
@@ -77,8 +83,6 @@
[
self
.
gradientMask
addAnimation
:
pathAnimation
forKey
:
@"animationKey"
];
self
.
gradientMask
.
path
=
progressline
.
CGPath
;
// add text
[
self
setGradeFrame
:
grade
startPosY
:
startPosY
];
CABasicAnimation
*
opacityAnimation
=
[
self
fadeAnimation
];
[
self
.
textLayer
addAnimation
:
opacityAnimation
forKey
:
nil
];
...
...
@@ -126,8 +130,6 @@
self
.
gradientMask
.
strokeEnd
=
1
.
0
;
[
self
.
gradientMask
addAnimation
:
pathAnimation
forKey
:
@"strokeEndAnimation"
];
//set grade
[
self
setGradeFrame
:
grade
startPosY
:
startPosY
];
CABasicAnimation
*
opacityAnimation
=
[
self
fadeAnimation
];
[
self
.
textLayer
addAnimation
:
opacityAnimation
forKey
:
nil
];
}
...
...
@@ -181,6 +183,7 @@
[
_textLayer
setString
:
@"0"
];
[
_textLayer
setAlignmentMode
:
kCAAlignmentCenter
];
[
_textLayer
setForegroundColor
:[[
UIColor
colorWithRed
:
178
/
255
.
0
green
:
178
/
255
.
blue
:
178
/
255
.
0
alpha
:
1
.
0
]
CGColor
]];
_textLayer
.
hidden
=
YES
;
}
return
_textLayer
;
...
...
@@ -215,6 +218,14 @@
}
-
(
void
)
setIsShowNumber
:
(
BOOL
)
isShowNumber
{
if
(
isShowNumber
)
{
self
.
textLayer
.
hidden
=
NO
;
[
self
setGradeFrame
:
_copyGrade
startPosY
:
0
];
}
else
{
self
.
textLayer
.
hidden
=
YES
;
}
}
-
(
void
)
setIsNegative
:
(
BOOL
)
isNegative
{
if
(
isNegative
)
{
[
self
.
textLayer
setString
:[[
NSString
alloc
]
initWithFormat
:
@"-%0.f"
,
_grade
*
self
.
maxDivisor
]];
...
...
PNChart/PNBarChart.h
View file @
98869cd
...
...
@@ -103,5 +103,10 @@ typedef NSString *(^PNYLabelFormatter)(CGFloat yLabelValue);
@property
(
nonatomic
,
weak
)
id
<
PNChartDelegate
>
delegate
;
/**whether show gradient bar*/
@property
(
nonatomic
,
assign
)
BOOL
isGradientShow
;
/** whether show numbers*/
@property
(
nonatomic
,
assign
)
BOOL
isShowNumbers
;
@end
...
...
PNChart/PNBarChart.m
View file @
98869cd
...
...
@@ -62,6 +62,8 @@
_showLevelLine
=
NO
;
_yChartLabelWidth
=
18
;
_rotateForXAxisText
=
false
;
_isGradientShow
=
YES
;
_isShowNumbers
=
YES
;
}
-
(
void
)
setYValues
:
(
NSArray
*
)
yValues
...
...
@@ -232,8 +234,11 @@
}
else
{
bar
.
barColor
=
[
self
barColorAtIndex
:
index
];
}
// Add gradient
if
(
self
.
isGradientShow
)
{
bar
.
barColorGradientStart
=
bar
.
barColor
;
}
//For Click Index
bar
.
tag
=
index
;
...
...
@@ -252,6 +257,7 @@
}
bar
.
maxDivisor
=
(
float
)
_yValueMax
;
bar
.
grade
=
grade
;
bar
.
isShowNumber
=
self
.
isShowNumbers
;
CGRect
originalFrame
=
bar
.
frame
;
if
(
value
<
0
&&
self
.
showLevelLine
)
{
CGAffineTransform
transform
=
CGAffineTransformMakeRotation
(
M_PI
);
...
...
@@ -259,7 +265,9 @@
originalFrame
.
origin
.
y
=
bar
.
frame
.
origin
.
y
+
bar
.
frame
.
size
.
height
;
bar
.
frame
=
originalFrame
;
bar
.
isNegative
=
YES
;
}
index
+=
1
;
}
...
...
PNChartDemo/PCChartViewController.m
View file @
98869cd
...
...
@@ -110,10 +110,9 @@
self
.
barChart
.
yValueMax
=
10
;
self
.
barChart
.
yLabels
=
@[
@
-
10
,
@0
,
@10
];
[
self
.
barChart
setYValues
:@[
@1
,
@5
,
@
(
0
-
8
),
@10
]];
[
self
.
barChart
setStrokeColors
:@[
PNGreen
,
PNGreen
,
PNRed
,
PNGreen
]];
// Adding gradient
// self.barChart.barColorGradientStart = [UIColor blueColor]
;
self
.
barChart
.
isGradientShow
=
NO
;
self
.
barChart
.
isShowNumbers
=
NO
;
[
self
.
barChart
strokeChart
];
...
...
Please
register
or
login
to post a comment