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 14:09:14 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1cffc39caa6490d276a525c8b205cfdf19a126e5
1cffc39c
1 parent
3da9b7f8
fix bugs
optimize gradient show
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
13 deletions
PNChart/PNBar.h
PNChart/PNBar.m
PNChart/PNBarChart.m
PNChartDemo/PCChartViewController.m
PNChart/PNBar.h
View file @
1cffc39
...
...
@@ -15,6 +15,8 @@
-
(
void
)
rollBack
;
@property
(
nonatomic
)
float
grade
;
@property
(
nonatomic
)
float
maxDivisor
;
@property
(
nonatomic
)
CAShapeLayer
*
chartLine
;
@property
(
nonatomic
)
UIColor
*
barColor
;
@property
(
nonatomic
)
UIColor
*
barColorGradientStart
;
...
...
PNChart/PNBar.m
View file @
1cffc39
...
...
@@ -108,13 +108,14 @@
CAGradientLayer
*
gradientLayer
=
[
CAGradientLayer
layer
];
gradientLayer
.
startPoint
=
CGPointMake
(
0
.
5
,
1
.
0
);
gradientLayer
.
endPoint
=
CGPointMake
(
0
.
5
,
0
.
0
);
gradientLayer
.
startPoint
=
CGPointMake
(
0
.
0
,
0
.
0
);
gradientLayer
.
endPoint
=
CGPointMake
(
1
.
0
,
0
.
0
);
gradientLayer
.
frame
=
CGRectMake
(
0
,
0
,
self
.
bounds
.
size
.
width
,
self
.
bounds
.
size
.
height
);
UIColor
*
endColor
=
(
_barColor
?
_barColor
:
[
UIColor
greenColor
])
;
UIColor
*
middleColor
=
[
UIColor
colorWithWhite
:
255
/
255
alpha
:
0
.
8
]
;
NSArray
*
colors
=
@[
(
id
)
_barColorGradientStart
.
CGColor
,
(
id
)
endColor
.
CGColor
(
__bridge
id
)
self
.
barColor
.
CGColor
,
(
__bridge
id
)
middleColor
.
CGColor
,
(
__bridge
id
)
self
.
barColor
.
CGColor
];
gradientLayer
.
colors
=
colors
;
...
...
@@ -202,7 +203,7 @@
[
_chartLine
addSublayer
:
self
.
textLayer
];
[
self
.
textLayer
setFontSize
:
textheigt
/
2
];
[
self
.
textLayer
setString
:[[
NSString
alloc
]
initWithFormat
:
@"%0.f"
,
grade
*
100
]];
[
self
.
textLayer
setString
:[[
NSString
alloc
]
initWithFormat
:
@"%0.f"
,
grade
*
self
.
maxDivisor
]];
[
self
.
textLayer
setFrame
:
CGRectMake
(
0
,
textStartPosY
,
textWidth
,
textheigt
)];
self
.
textLayer
.
contentsScale
=
[
UIScreen
mainScreen
].
scale
;
...
...
@@ -210,7 +211,7 @@
-
(
void
)
setIsNegative
:
(
BOOL
)
isNegative
{
if
(
isNegative
)
{
[
self
.
textLayer
setString
:[[
NSString
alloc
]
initWithFormat
:
@"-%0.f"
,
_grade
*
100
]];
[
self
.
textLayer
setString
:[[
NSString
alloc
]
initWithFormat
:
@"-%0.f"
,
_grade
*
self
.
maxDivisor
]];
CABasicAnimation
*
rotationAnimation
;
rotationAnimation
=
[
CABasicAnimation
animationWithKeyPath
:
@"transform.rotation.z"
];
rotationAnimation
.
toValue
=
[
NSNumber
numberWithFloat
:
M_PI
];
...
...
PNChart/PNBarChart.m
View file @
1cffc39
...
...
@@ -233,7 +233,7 @@
bar
.
barColor
=
[
self
barColorAtIndex
:
index
];
}
// Add gradient
bar
.
barColorGradientStart
=
_barColorGradientStart
;
bar
.
barColorGradientStart
=
bar
.
barColor
;
//For Click Index
bar
.
tag
=
index
;
...
...
@@ -250,8 +250,9 @@
if
(
isnan
(
grade
))
{
grade
=
0
;
}
bar
.
maxDivisor
=
(
float
)
_yValueMax
;
bar
.
grade
=
grade
;
CGRect
originalFrame
=
bar
.
frame
;
CGRect
originalFrame
=
bar
.
frame
;
if
(
value
<
0
&&
self
.
showLevelLine
)
{
CGAffineTransform
transform
=
CGAffineTransformMakeRotation
(
M_PI
);
[
bar
setTransform
:
transform
];
...
...
PNChartDemo/PCChartViewController.m
View file @
1cffc39
...
...
@@ -107,14 +107,14 @@
self
.
barChart
.
rotateForXAxisText
=
true
;
self
.
barChart
.
yLabelSum
=
5
;
self
.
barChart
.
y
MaxValue
=
10
0
;
self
.
barChart
.
y
ValueMax
=
1
0
;
self
.
barChart
.
yLabels
=
@[
@
-
10
,
@0
,
@10
];
[
self
.
barChart
setYValues
:@[
@1
,
@
24
,
@
(
0
-
12
),
@18
]];
[
self
.
barChart
setYValues
:@[
@1
,
@
5
,
@
(
0
-
8
),
@10
]];
[
self
.
barChart
setStrokeColors
:@[
PNGreen
,
PNGreen
,
PNRed
,
PNGreen
,
PNGreen
,
PNYellow
,
PNGreen
]];
[
self
.
barChart
setStrokeColors
:@[
PNGreen
,
PNGreen
,
PNRed
,
PNGreen
]];
// Adding gradient
self
.
barChart
.
barColorGradientStart
=
[
UIColor
blueColor
];
[
self
.
barChart
strokeChart
];
self
.
barChart
.
delegate
=
self
;
...
...
Please
register
or
login
to post a comment