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
kevinzhow
2014-05-19 13:20:07 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4e67a624b214f6e1db257a2353800189b171ede4
4e67a624
1 parent
42123c18
add highlight on bar animation #58
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
12 deletions
PNChart/PNBarChart/PNBarChart.h
PNChart/PNBarChart/PNBarChart.m
PNChartDemo/PCChartsTableViewController.h
PNChartDemo/PCChartsTableViewController.m
PNChart/PNBarChart/PNBarChart.h
View file @
4e67a62
...
...
@@ -8,6 +8,7 @@
#import <UIKit/UIKit.h>
#import "PNChartDelegate.h"
#import "PNBar.h"
#define xLabelMargin 15
#define yLabelMargin 15
...
...
@@ -27,6 +28,9 @@ typedef NSString *(^PNyLabelFromatter)(CGFloat yLabelValue);
@property
(
nonatomic
)
NSArray
*
xLabels
;
@property
(
nonatomic
)
NSArray
*
yLabels
;
@property
(
nonatomic
)
NSArray
*
yValues
;
@property
(
nonatomic
)
NSMutableArray
*
bars
;
@property
(
nonatomic
)
CGFloat
xLabelWidth
;
@property
(
nonatomic
)
int
yValueMax
;
@property
(
nonatomic
)
UIColor
*
strokeColor
;
...
...
PNChart/PNBarChart/PNBarChart.m
View file @
4e67a62
...
...
@@ -9,10 +9,9 @@
#import "PNBarChart.h"
#import "PNColor.h"
#import "PNChartLabel.h"
#import "PNBar.h"
@interface
PNBarChart
()
{
NSMutableArray
*
_bars
;
NSMutableArray
*
_labels
;
}
...
...
PNChartDemo/PCChartsTableViewController.h
View file @
4e67a62
...
...
@@ -8,7 +8,10 @@
#import <UIKit/UIKit.h>
#import "PNChartDelegate.h"
#import "PNChart.h"
@interface
PCChartsTableViewController
:
UITableViewController
<
PNChartDelegate
>
@property
(
nonatomic
)
PNBarChart
*
barChart
;
@end
...
...
PNChartDemo/PCChartsTableViewController.m
View file @
4e67a62
...
...
@@ -105,23 +105,23 @@
barChartLabel
.
font
=
[
UIFont
fontWithName
:
@"Avenir-Medium"
size
:
23
.
0
];
barChartLabel
.
textAlignment
=
NSTextAlignmentCenter
;
PNBarChart
*
barChart
=
[[
PNBarChart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
135
.
0
,
SCREEN_WIDTH
,
200
.
0
)];
barChart
.
backgroundColor
=
[
UIColor
clearColor
];
barChart
.
yLabelFormatter
=
^
(
CGFloat
yValue
){
self
.
barChart
=
[[
PNBarChart
alloc
]
initWithFrame
:
CGRectMake
(
0
,
135
.
0
,
SCREEN_WIDTH
,
200
.
0
)];
self
.
barChart
.
backgroundColor
=
[
UIColor
clearColor
];
self
.
barChart
.
yLabelFormatter
=
^
(
CGFloat
yValue
){
CGFloat
yValueParsed
=
yValue
;
NSString
*
labelText
=
[
NSString
stringWithFormat
:
@"%1.f"
,
yValueParsed
];
return
labelText
;
};
barChart
.
labelMarginTop
=
5
.
0
;
[
barChart
setXLabels
:@[
@"SEP 1"
,
@"SEP 2"
,
@"SEP 3"
,
@"SEP 4"
,
@"SEP 5"
,
@"SEP 6"
,
@"SEP 7"
]];
[
barChart
setYValues
:@[
@1
,
@24
,
@12
,
@18
,
@30
,
@10
,
@21
]];
[
barChart
setStrokeColors
:@[
PNGreen
,
PNGreen
,
PNRed
,
PNGreen
,
PNGreen
,
PNYellow
,
PNGreen
]];
[
barChart
strokeChart
];
self
.
barChart
.
labelMarginTop
=
5
.
0
;
[
self
.
barChart
setXLabels
:@[
@"SEP 1"
,
@"SEP 2"
,
@"SEP 3"
,
@"SEP 4"
,
@"SEP 5"
,
@"SEP 6"
,
@"SEP 7"
]];
[
self
.
barChart
setYValues
:@[
@1
,
@24
,
@12
,
@18
,
@30
,
@10
,
@21
]];
[
self
.
barChart
setStrokeColors
:@[
PNGreen
,
PNGreen
,
PNRed
,
PNGreen
,
PNGreen
,
PNYellow
,
PNGreen
]];
[
self
.
barChart
strokeChart
];
barChart
.
delegate
=
self
;
self
.
barChart
.
delegate
=
self
;
[
viewController
.
view
addSubview
:
barChartLabel
];
[
viewController
.
view
addSubview
:
barChart
];
[
viewController
.
view
addSubview
:
self
.
barChart
];
viewController
.
title
=
@"Bar Chart"
;
}
else
if
([
segue
.
identifier
isEqualToString
:
@"circleChart"
])
...
...
@@ -191,7 +191,30 @@
-
(
void
)
userClickedOnBarCharIndex
:
(
NSInteger
)
barIndex
{
NSLog
(
@"Click on bar %@"
,
@
(
barIndex
));
PNBar
*
bar
=
[
self
.
barChart
.
bars
objectAtIndex
:
barIndex
];
CABasicAnimation
*
animation
=
[
CABasicAnimation
animationWithKeyPath
:
@"transform.scale"
];
animation
.
fromValue
=
@1.0
;
animation
.
timingFunction
=
[
CAMediaTimingFunction
functionWithName
:
kCAMediaTimingFunctionEaseInEaseOut
];
animation
.
toValue
=
@1.1
;
animation
.
duration
=
0
.
2
;
animation
.
repeatCount
=
0
;
animation
.
autoreverses
=
YES
;
animation
.
removedOnCompletion
=
YES
;
animation
.
fillMode
=
kCAFillModeForwards
;
[
bar
.
layer
addAnimation
:
animation
forKey
:
@"Float"
];
}
@end
...
...
Please
register
or
login
to post a comment