Orlando Aleman Ortiz

Reformatting

... ... @@ -11,12 +11,9 @@
@interface PNBar : UIView
@property (nonatomic) float grade;
@property (nonatomic,strong) CAShapeLayer * chartLine;
@property (nonatomic, strong) UIColor * barColor;
-(void)rollBack;
- (void)rollBack;
@property (nonatomic) float grade;
@property (nonatomic, strong) CAShapeLayer *chartLine;
@property (nonatomic, strong) UIColor *barColor;
@end
... ...
... ... @@ -14,6 +14,7 @@
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
_chartLine = [CAShapeLayer layer];
... ... @@ -22,57 +23,61 @@
_chartLine.lineWidth = self.frame.size.width;
_chartLine.strokeEnd = 0.0;
self.clipsToBounds = YES;
[self.layer addSublayer:_chartLine];
[self.layer addSublayer:_chartLine];
self.layer.cornerRadius = 2.0;
}
return self;
}
-(void)setGrade:(float)grade
- (void)setGrade:(float)grade
{
_grade = grade;
UIBezierPath *progressline = [UIBezierPath bezierPath];
[progressline moveToPoint:CGPointMake(self.frame.size.width/2.0, self.frame.size.height)];
[progressline addLineToPoint:CGPointMake(self.frame.size.width/2.0, (1 - grade) * self.frame.size.height)];
_grade = grade;
UIBezierPath *progressline = [UIBezierPath bezierPath];
[progressline moveToPoint:CGPointMake(self.frame.size.width / 2.0, self.frame.size.height)];
[progressline addLineToPoint:CGPointMake(self.frame.size.width / 2.0, (1 - grade) * self.frame.size.height)];
[progressline setLineWidth:1.0];
[progressline setLineCapStyle:kCGLineCapSquare];
_chartLine.path = progressline.CGPath;
if (_barColor) {
_chartLine.strokeColor = [_barColor CGColor];
}else{
_chartLine.strokeColor = [PNGreen CGColor];
}
_chartLine.path = progressline.CGPath;
if (_barColor) {
_chartLine.strokeColor = [_barColor CGColor];
}
else {
_chartLine.strokeColor = [PNGreen CGColor];
}
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 1.0;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
[_chartLine addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
_chartLine.strokeEnd = 1.0;
}
-(void)rollBack{
[UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
- (void)rollBack
{
[UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations: ^{
_chartLine.strokeColor = [UIColor clearColor].CGColor;
} completion:nil];
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
//Draw BG
//Draw BG
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, self.backgroundColor.CGColor);
CGContextFillRect(context, rect);
CGContextFillRect(context, rect);
}
... ...
... ... @@ -8,11 +8,11 @@
#import <UIKit/UIKit.h>
#define chartMargin 10
#define xLabelMargin 15
#define yLabelMargin 15
#define yLabelHeight 11
#define xLabelHeight 20
#define chartMargin 10
#define xLabelMargin 15
#define yLabelMargin 15
#define yLabelHeight 11
#define xLabelHeight 20
@interface PNBarChart : UIView
... ... @@ -20,24 +20,15 @@
* This method will call and stroke the line in animation
*/
-(void)strokeChart;
@property (strong, nonatomic) NSArray * xLabels;
@property (strong, nonatomic) NSArray * yLabels;
@property (strong, nonatomic) NSArray * yValues;
- (void)strokeChart;
@property (strong, nonatomic) NSArray *xLabels;
@property (strong, nonatomic) NSArray *yLabels;
@property (strong, nonatomic) NSArray *yValues;
@property (nonatomic) CGFloat xLabelWidth;
@property (nonatomic) int yValueMax;
@property (nonatomic, strong) UIColor * strokeColor;
@property (nonatomic, strong) NSArray * strokeColors;
@property (nonatomic, strong) UIColor * barBackgroundColor;
@property (nonatomic, strong) UIColor *strokeColor;
@property (nonatomic, strong) NSArray *strokeColors;
@property (nonatomic, strong) UIColor *barBackgroundColor;
@property (nonatomic) BOOL showLabel;
@end
... ...
... ... @@ -11,9 +11,9 @@
#import "PNChartLabel.h"
#import "PNBar.h"
@interface PNBarChart() {
NSMutableArray* _bars;
NSMutableArray* _labels;
@interface PNBarChart () {
NSMutableArray *_bars;
NSMutableArray *_labels;
}
- (UIColor *)barColorAtIndex:(NSUInteger)index;
... ... @@ -24,6 +24,7 @@
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
self.backgroundColor = [UIColor whiteColor];
... ... @@ -33,94 +34,100 @@
_labels = [NSMutableArray array];
_bars = [NSMutableArray array];
}
return self;
}
-(void)setYValues:(NSArray *)yValues
- (void)setYValues:(NSArray *)yValues
{
_yValues = yValues;
[self setYLabels:yValues];
_xLabelWidth = (self.frame.size.width - chartMargin*2)/[_yValues count];
_xLabelWidth = (self.frame.size.width - chartMargin * 2) / [_yValues count];
}
-(void)setYLabels:(NSArray *)yLabels
- (void)setYLabels:(NSArray *)yLabels
{
NSInteger max = 0;
for (NSString * valueString in yLabels) {
for (NSString *valueString in yLabels) {
NSInteger value = [valueString integerValue];
if (value > max) {
max = value;
}
}
//Min value for Y label
if (max < 5) {
max = 5;
}
_yValueMax = (int)max;
}
-(void)setXLabels:(NSArray *)xLabels
- (void)setXLabels:(NSArray *)xLabels
{
_xLabels = xLabels;
if (_showLabel) {
_xLabelWidth = (self.frame.size.width - chartMargin*2)/[xLabels count];
_xLabelWidth = (self.frame.size.width - chartMargin * 2) / [xLabels count];
}
}
-(void)setStrokeColor:(UIColor *)strokeColor
- (void)setStrokeColor:(UIColor *)strokeColor
{
_strokeColor = strokeColor;
_strokeColor = strokeColor;
}
-(void)strokeChart
- (void)strokeChart
{
[self viewCleanupForCollection:_labels];
for(int index = 0; index < _xLabels.count; index++)
{
NSString* labelText = _xLabels[index];
PNChartLabel * label = [[PNChartLabel alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin), self.frame.size.height - xLabelHeight - chartMargin, _xLabelWidth, xLabelHeight)];
for (int index = 0; index < _xLabels.count; index++) {
NSString *labelText = _xLabels[index];
PNChartLabel *label = [[PNChartLabel alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin), self.frame.size.height - xLabelHeight - chartMargin, _xLabelWidth, xLabelHeight)];
[label setTextAlignment:NSTextAlignmentCenter];
label.text = labelText;
[_labels addObject:label];
[self addSubview:label];
}
[self viewCleanupForCollection:_bars];
CGFloat chartCavanHeight = self.frame.size.height - chartMargin*2 - xLabelHeight*2;
CGFloat chartCavanHeight = self.frame.size.height - chartMargin * 2 - xLabelHeight * 2;
NSInteger index = 0;
for (NSString * valueString in _yValues) {
for (NSString *valueString in _yValues) {
float value = [valueString floatValue];
float grade = (float)value / (float)_yValueMax;
PNBar * bar;
PNBar *bar;
if (_showLabel) {
bar = [[PNBar alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin + _xLabelWidth * 0.25), self.frame.size.height - chartCavanHeight - xLabelHeight - chartMargin, _xLabelWidth * 0.5, chartCavanHeight)];
}
else{
bar = [[PNBar alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin + _xLabelWidth * 0.25), self.frame.size.height - chartCavanHeight , _xLabelWidth * 0.6, chartCavanHeight)];
else {
bar = [[PNBar alloc] initWithFrame:CGRectMake((index * _xLabelWidth + chartMargin + _xLabelWidth * 0.25), self.frame.size.height - chartCavanHeight, _xLabelWidth * 0.6, chartCavanHeight)];
}
bar.backgroundColor = _barBackgroundColor;
bar.barColor = [self barColorAtIndex:index];
bar.grade = grade;
[_bars addObject:bar];
[self addSubview:bar];
index += 1;
}
}
- (void)viewCleanupForCollection:(NSMutableArray*)array
- (void)viewCleanupForCollection:(NSMutableArray *)array
{
if (array.count) {
[array makeObjectsPerformSelector:@selector(removeFromSuperview)];
... ... @@ -128,15 +135,18 @@
}
}
#pragma mark - Class extension methods
- (UIColor *)barColorAtIndex:(NSUInteger)index
{
if ([self.strokeColors count] == [self.yValues count]) {
return self.strokeColors[index];
} else {
}
else {
return self.strokeColor;
}
}
@end
... ...
... ... @@ -14,13 +14,13 @@
* When user click on the chart line
*
*/
- (void)userClickedOnLinePoint:(CGPoint )point lineIndex:(NSInteger)lineIndex;
- (void)userClickedOnLinePoint:(CGPoint)point lineIndex:(NSInteger)lineIndex;
/**
* When user click on the chart line key point
*
*/
- (void)userClickedOnLineKeyPoint:(CGPoint )point lineIndex:(NSInteger)lineIndex andPointIndex:(NSInteger)pointIndex;
- (void)userClickedOnLineKeyPoint:(CGPoint)point lineIndex:(NSInteger)lineIndex andPointIndex:(NSInteger)pointIndex;
@end
... ...
... ... @@ -14,27 +14,20 @@
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self setLineBreakMode:NSLineBreakByWordWrapping];
[self setMinimumScaleFactor:11.0f];
[self setNumberOfLines:0];
[self setFont:[UIFont boldSystemFontOfSize:11.0f]];
[self setTextColor: PNDeepGrey];
[self setTextColor:PNDeepGrey];
self.backgroundColor = [UIColor clearColor];
[self setTextAlignment:NSTextAlignmentLeft];
self.userInteractionEnabled = YES;
}
return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
return self;
}
*/
@end
... ...
... ... @@ -14,17 +14,17 @@
@interface PNCircleChart : UIView
-(void)strokeChart;
- (void)strokeChart;
- (id)initWithFrame:(CGRect)frame andTotal:(NSNumber *)total andCurrent:(NSNumber *)current andClockwise:(BOOL)clockwise;
@property (nonatomic, strong) UIColor *strokeColor;
@property (nonatomic, strong) UIColor *labelColor;
@property (nonatomic, strong) NSNumber * total;
@property (nonatomic, strong) NSNumber * current;
@property (nonatomic, strong) NSNumber * lineWidth;
@property (nonatomic, strong) NSNumber *total;
@property (nonatomic, strong) NSNumber *current;
@property (nonatomic, strong) NSNumber *lineWidth;
@property (nonatomic) BOOL clockwise;
@property(nonatomic,strong) CAShapeLayer * circle;
@property(nonatomic,strong) CAShapeLayer * circleBG;
@property (nonatomic, strong) CAShapeLayer *circle;
@property (nonatomic, strong) CAShapeLayer *circleBG;
@end
... ...
... ... @@ -22,25 +22,27 @@
if (!_labelColor) {
_labelColor = PNDeepGrey;
}
return _labelColor;
}
- (id)initWithFrame:(CGRect)frame andTotal:(NSNumber *)total andCurrent:(NSNumber *)current andClockwise:(BOOL)clockwise {
- (id)initWithFrame:(CGRect)frame andTotal:(NSNumber *)total andCurrent:(NSNumber *)current andClockwise:(BOOL)clockwise
{
self = [super initWithFrame:frame];
if (self) {
_total = total;
_current = current;
_strokeColor = PNFreshGreen;
_clockwise = clockwise;
CGFloat startAngle = clockwise ? -90.0f : 270.0f;
CGFloat endAngle = clockwise ? -90.01f : 270.01f;
_clockwise = clockwise;
CGFloat startAngle = clockwise ? -90.0f : 270.0f;
CGFloat endAngle = clockwise ? -90.01f : 270.01f;
_lineWidth = [NSNumber numberWithFloat:8.0];
UIBezierPath* circlePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.center.x,self.center.y) radius:self.frame.size.height*0.5 startAngle:DEGREES_TO_RADIANS(startAngle) endAngle:DEGREES_TO_RADIANS(endAngle) clockwise:clockwise];
UIBezierPath *circlePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.center.x, self.center.y) radius:self.frame.size.height * 0.5 startAngle:DEGREES_TO_RADIANS(startAngle) endAngle:DEGREES_TO_RADIANS(endAngle) clockwise:clockwise];
_circle = [CAShapeLayer layer];
_circle.path = circlePath.CGPath;
_circle.lineCap = kCALineCapRound;
... ... @@ -56,50 +58,49 @@
_circleBG.strokeColor = PNLightYellow.CGColor;
_circleBG.strokeEnd = 1.0;
_circleBG.zPosition = -1;
[self.layer addSublayer:_circle];
[self.layer addSublayer:_circleBG];
_gradeLabel = [[UICountingLabel alloc] initWithFrame:CGRectMake(0, 0, 50.0, 50.0)];
_gradeLabel = [[UICountingLabel alloc] initWithFrame:CGRectMake(0, 0, 50.0, 50.0)];
}
return self;
}
-(void)strokeChart
- (void)strokeChart
{
//Add count label
[_gradeLabel setTextAlignment:NSTextAlignmentCenter];
[_gradeLabel setFont:[UIFont boldSystemFontOfSize:13.0f]];
[_gradeLabel setTextColor:self.labelColor];
[_gradeLabel setCenter:CGPointMake(self.center.x,self.center.y)];
[_gradeLabel setCenter:CGPointMake(self.center.x, self.center.y)];
_gradeLabel.method = UILabelCountingMethodEaseInOut;
_gradeLabel.format = @"%d%%";
[self addSubview:_gradeLabel];
//Add circle params
_circle.lineWidth = [_lineWidth floatValue];
_circleBG.lineWidth = [_lineWidth floatValue];
_circleBG.strokeEnd = 1.0;
_circle.strokeColor = _strokeColor.CGColor;
//Add Animation
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 1.0;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:[_current floatValue]/[_total floatValue]];
pathAnimation.toValue = [NSNumber numberWithFloat:[_current floatValue] / [_total floatValue]];
[_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
_circle.strokeEnd = [_current floatValue]/[_total floatValue];
[_gradeLabel countFrom:0 to:[_current floatValue]/[_total floatValue]*100 withDuration:1.0];
_circle.strokeEnd = [_current floatValue] / [_total floatValue];
[_gradeLabel countFrom:0 to:[_current floatValue] / [_total floatValue] * 100 withDuration:1.0];
}
@end
... ...
... ... @@ -7,45 +7,44 @@
//
#import <Foundation/Foundation.h>
/*
* System Versioning Preprocessor Macros
*/
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define PNGrey [UIColor colorWithRed:246.0/255.0 green:246.0/255.0 blue:246.0/255.0 alpha:1.0f]
#define PNLightBlue [UIColor colorWithRed:94.0/255.0 green:147.0/255.0 blue:196.0/255.0 alpha:1.0f]
#define PNGreen [UIColor colorWithRed:77.0/255.0 green:186.0/255.0 blue:122.0/255.0 alpha:1.0f]
#define PNTitleColor [UIColor colorWithRed:0.0/255.0 green:189.0/255.0 blue:113.0/255.0 alpha:1.0f]
#define PNButtonGrey [UIColor colorWithRed:141.0/255.0 green:141.0/255.0 blue:141.0/255.0 alpha:1.0f]
#define PNFreshGreen [UIColor colorWithRed:77.0/255.0 green:196.0/255.0 blue:122.0/255.0 alpha:1.0f]
#define PNRed [UIColor colorWithRed:245.0/255.0 green:94.0/255.0 blue:78.0/255.0 alpha:1.0f]
#define PNMauve [UIColor colorWithRed:88.0/255.0 green:75.0/255.0 blue:103.0/255.0 alpha:1.0f]
#define PNBrown [UIColor colorWithRed:119.0/255.0 green:107.0/255.0 blue:95.0/255.0 alpha:1.0f]
#define PNBlue [UIColor colorWithRed:82.0/255.0 green:116.0/255.0 blue:188.0/255.0 alpha:1.0f]
#define PNDarkBlue [UIColor colorWithRed:121.0/255.0 green:134.0/255.0 blue:142.0/255.0 alpha:1.0f]
#define PNYellow [UIColor colorWithRed:242.0/255.0 green:197.0/255.0 blue:117.0/255.0 alpha:1.0f]
#define PNWhite [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0f]
#define PNDeepGrey [UIColor colorWithRed:99.0/255.0 green:99.0/255.0 blue:99.0/255.0 alpha:1.0f]
#define PNPinkGrey [UIColor colorWithRed:200.0/255.0 green:193.0/255.0 blue:193.0/255.0 alpha:1.0f]
#define PNHealYellow [UIColor colorWithRed:245.0/255.0 green:242.0/255.0 blue:238.0/255.0 alpha:1.0f]
#define PNLightGrey [UIColor colorWithRed:225.0/255.0 green:225.0/255.0 blue:225.0/255.0 alpha:1.0f]
#define PNCleanGrey [UIColor colorWithRed:251.0/255.0 green:251.0/255.0 blue:251.0/255.0 alpha:1.0f]
#define PNLightYellow [UIColor colorWithRed:241.0/255.0 green:240.0/255.0 blue:240.0/255.0 alpha:1.0f]
#define PNDarkYellow [UIColor colorWithRed:152.0/255.0 green:150.0/255.0 blue:159.0/255.0 alpha:1.0f]
#define PNPinkDark [UIColor colorWithRed:170.0/255.0 green:165.0/255.0 blue:165.0/255.0 alpha:1.0f]
#define PNCloudWhite [UIColor colorWithRed:244.0/255.0 green:244.0/255.0 blue:244.0/255.0 alpha:1.0f]
#define PNBlack [UIColor colorWithRed:45.0/255.0 green:45.0/255.0 blue:45.0/255.0 alpha:1.0f]
#define PNStarYellow [UIColor colorWithRed:252.0/255.0 green:223.0/255.0 blue:101.0/255.0 alpha:1.0f]
#define PNTwitterColor [UIColor colorWithRed:0.0/255.0 green:171.0/255.0 blue:243.0/255.0 alpha:1.0]
#define PNWeiboColor [UIColor colorWithRed:250.0/255.0 green:0.0/255.0 blue:33.0/255.0 alpha:1.0]
#define PNiOSGreenColor [UIColor colorWithRed:98.0/255.0 green:247.0/255.0 blue:77.0/255.0 alpha:1.0]
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define PNGrey [UIColor colorWithRed:246.0 / 255.0 green:246.0 / 255.0 blue:246.0 / 255.0 alpha:1.0f]
#define PNLightBlue [UIColor colorWithRed:94.0 / 255.0 green:147.0 / 255.0 blue:196.0 / 255.0 alpha:1.0f]
#define PNGreen [UIColor colorWithRed:77.0 / 255.0 green:186.0 / 255.0 blue:122.0 / 255.0 alpha:1.0f]
#define PNTitleColor [UIColor colorWithRed:0.0 / 255.0 green:189.0 / 255.0 blue:113.0 / 255.0 alpha:1.0f]
#define PNButtonGrey [UIColor colorWithRed:141.0 / 255.0 green:141.0 / 255.0 blue:141.0 / 255.0 alpha:1.0f]
#define PNFreshGreen [UIColor colorWithRed:77.0 / 255.0 green:196.0 / 255.0 blue:122.0 / 255.0 alpha:1.0f]
#define PNRed [UIColor colorWithRed:245.0 / 255.0 green:94.0 / 255.0 blue:78.0 / 255.0 alpha:1.0f]
#define PNMauve [UIColor colorWithRed:88.0 / 255.0 green:75.0 / 255.0 blue:103.0 / 255.0 alpha:1.0f]
#define PNBrown [UIColor colorWithRed:119.0 / 255.0 green:107.0 / 255.0 blue:95.0 / 255.0 alpha:1.0f]
#define PNBlue [UIColor colorWithRed:82.0 / 255.0 green:116.0 / 255.0 blue:188.0 / 255.0 alpha:1.0f]
#define PNDarkBlue [UIColor colorWithRed:121.0 / 255.0 green:134.0 / 255.0 blue:142.0 / 255.0 alpha:1.0f]
#define PNYellow [UIColor colorWithRed:242.0 / 255.0 green:197.0 / 255.0 blue:117.0 / 255.0 alpha:1.0f]
#define PNWhite [UIColor colorWithRed:255.0 / 255.0 green:255.0 / 255.0 blue:255.0 / 255.0 alpha:1.0f]
#define PNDeepGrey [UIColor colorWithRed:99.0 / 255.0 green:99.0 / 255.0 blue:99.0 / 255.0 alpha:1.0f]
#define PNPinkGrey [UIColor colorWithRed:200.0 / 255.0 green:193.0 / 255.0 blue:193.0 / 255.0 alpha:1.0f]
#define PNHealYellow [UIColor colorWithRed:245.0 / 255.0 green:242.0 / 255.0 blue:238.0 / 255.0 alpha:1.0f]
#define PNLightGrey [UIColor colorWithRed:225.0 / 255.0 green:225.0 / 255.0 blue:225.0 / 255.0 alpha:1.0f]
#define PNCleanGrey [UIColor colorWithRed:251.0 / 255.0 green:251.0 / 255.0 blue:251.0 / 255.0 alpha:1.0f]
#define PNLightYellow [UIColor colorWithRed:241.0 / 255.0 green:240.0 / 255.0 blue:240.0 / 255.0 alpha:1.0f]
#define PNDarkYellow [UIColor colorWithRed:152.0 / 255.0 green:150.0 / 255.0 blue:159.0 / 255.0 alpha:1.0f]
#define PNPinkDark [UIColor colorWithRed:170.0 / 255.0 green:165.0 / 255.0 blue:165.0 / 255.0 alpha:1.0f]
#define PNCloudWhite [UIColor colorWithRed:244.0 / 255.0 green:244.0 / 255.0 blue:244.0 / 255.0 alpha:1.0f]
#define PNBlack [UIColor colorWithRed:45.0 / 255.0 green:45.0 / 255.0 blue:45.0 / 255.0 alpha:1.0f]
#define PNStarYellow [UIColor colorWithRed:252.0 / 255.0 green:223.0 / 255.0 blue:101.0 / 255.0 alpha:1.0f]
#define PNTwitterColor [UIColor colorWithRed:0.0 / 255.0 green:171.0 / 255.0 blue:243.0 / 255.0 alpha:1.0]
#define PNWeiboColor [UIColor colorWithRed:250.0 / 255.0 green:0.0 / 255.0 blue:33.0 / 255.0 alpha:1.0]
#define PNiOSGreenColor [UIColor colorWithRed:98.0 / 255.0 green:247.0 / 255.0 blue:77.0 / 255.0 alpha:1.0]
@interface PNColor : NSObject
- (UIImage *)imageFromColor:(UIColor *)color;
@end
... ...
... ... @@ -10,19 +10,10 @@
@implementation PNColor
-(id)init{
if (self = [super init]) {
}
return self;
}
-(UIImage *)imageFromColor:(UIColor*)color
- (UIImage *)imageFromColor:(UIColor *)color
{
CGRect rect = CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context,
... ... @@ -35,6 +26,4 @@
}
@end
... ...
... ... @@ -6,14 +6,11 @@
// Copyright (c) 2013年 kevinzhow. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import "PNChartDelegate.h"
@interface PNLineChart : UIView
/**
... ... @@ -22,18 +19,18 @@
- (void)strokeChart;
@property(nonatomic,retain) id<PNChartDelegate> delegate;
@property (nonatomic, retain) id<PNChartDelegate> delegate;
@property (strong, nonatomic) NSArray * xLabels;
@property (strong, nonatomic) NSArray *xLabels;
@property (strong, nonatomic) NSArray * yLabels;
@property (strong, nonatomic) NSArray *yLabels;
/**
* Array of `LineChartData` objects, one for each line.
*/
@property (strong, nonatomic) NSArray *chartData;
@property (strong, nonatomic) NSMutableArray * pathPoints;
@property (strong, nonatomic) NSMutableArray *pathPoints;
@property (nonatomic) CGFloat xLabelWidth;
... ...
This diff is collapsed. Click to expand it.
... ... @@ -7,18 +7,12 @@
@class PNLineChartDataItem;
typedef PNLineChartDataItem *(^LCLineChartDataGetter)(NSUInteger item);
/**
*
*/
@interface PNLineChartData : NSObject
@property (strong) UIColor *color;
@property NSUInteger itemCount;
@property (copy) LCLineChartDataGetter getData;
@end
... ...
... ... @@ -5,10 +5,10 @@
#import <Foundation/Foundation.h>
@interface PNLineChartDataItem : NSObject
@property (readonly) CGFloat y; // should be within the y range
@interface PNLineChartDataItem : NSObject
+ (PNLineChartDataItem *)dataItemWithY:(CGFloat)y;
@property (readonly) CGFloat y; // should be within the y range
@end
... ...
... ... @@ -5,30 +5,35 @@
#import "PNLineChartDataItem.h"
//------------------------------------------------------------------------------------------------
// private interface declaration
//------------------------------------------------------------------------------------------------
@interface PNLineChartDataItem ()
- (id)initWithY:(CGFloat)y;
@property (readwrite) CGFloat y; // should be within the y range
@end
- (id)initWithY:(CGFloat)y;
@end
//------------------------------------------------------------------------------------------------
// public interface implementation
//------------------------------------------------------------------------------------------------
@implementation PNLineChartDataItem
+ (PNLineChartDataItem *)dataItemWithY:(CGFloat)y {
+ (PNLineChartDataItem *)dataItemWithY:(CGFloat)y
{
return [[PNLineChartDataItem alloc] initWithY:y];
}
- (id)initWithY:(CGFloat)y {
- (id)initWithY:(CGFloat)y
{
if ((self = [super init])) {
self.y = y;
}
return self;
}
... ...