Showing
4 changed files
with
17 additions
and
13 deletions
| @@ -15,6 +15,8 @@ | @@ -15,6 +15,8 @@ | ||
| 15 | - (void)rollBack; | 15 | - (void)rollBack; |
| 16 | 16 | ||
| 17 | @property (nonatomic) float grade; | 17 | @property (nonatomic) float grade; |
| 18 | +@property (nonatomic) float maxDivisor; | ||
| 19 | + | ||
| 18 | @property (nonatomic) CAShapeLayer *chartLine; | 20 | @property (nonatomic) CAShapeLayer *chartLine; |
| 19 | @property (nonatomic) UIColor *barColor; | 21 | @property (nonatomic) UIColor *barColor; |
| 20 | @property (nonatomic) UIColor *barColorGradientStart; | 22 | @property (nonatomic) UIColor *barColorGradientStart; |
| @@ -108,13 +108,14 @@ | @@ -108,13 +108,14 @@ | ||
| 108 | 108 | ||
| 109 | 109 | ||
| 110 | CAGradientLayer *gradientLayer = [CAGradientLayer layer]; | 110 | CAGradientLayer *gradientLayer = [CAGradientLayer layer]; |
| 111 | - gradientLayer.startPoint = CGPointMake(0.5,1.0); | 111 | + gradientLayer.startPoint = CGPointMake(0.0,0.0); |
| 112 | - gradientLayer.endPoint = CGPointMake(0.5,0.0); | 112 | + gradientLayer.endPoint = CGPointMake(1.0 ,0.0); |
| 113 | gradientLayer.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height); | 113 | gradientLayer.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height); |
| 114 | - UIColor *endColor = (_barColor ? _barColor : [UIColor greenColor]); | 114 | + UIColor *middleColor = [UIColor colorWithWhite:255/255 alpha:0.8]; |
| 115 | NSArray *colors = @[ | 115 | NSArray *colors = @[ |
| 116 | - (id)_barColorGradientStart.CGColor, | 116 | + (__bridge id)self.barColor.CGColor, |
| 117 | - (id)endColor.CGColor | 117 | + (__bridge id)middleColor.CGColor, |
| 118 | + (__bridge id)self.barColor.CGColor | ||
| 118 | ]; | 119 | ]; |
| 119 | gradientLayer.colors = colors; | 120 | gradientLayer.colors = colors; |
| 120 | 121 | ||
| @@ -202,7 +203,7 @@ | @@ -202,7 +203,7 @@ | ||
| 202 | [_chartLine addSublayer:self.textLayer]; | 203 | [_chartLine addSublayer:self.textLayer]; |
| 203 | [self.textLayer setFontSize:textheigt/2]; | 204 | [self.textLayer setFontSize:textheigt/2]; |
| 204 | 205 | ||
| 205 | - [self.textLayer setString:[[NSString alloc]initWithFormat:@"%0.f",grade*100]]; | 206 | + [self.textLayer setString:[[NSString alloc]initWithFormat:@"%0.f",grade*self.maxDivisor]]; |
| 206 | [self.textLayer setFrame:CGRectMake(0, textStartPosY, textWidth, textheigt)]; | 207 | [self.textLayer setFrame:CGRectMake(0, textStartPosY, textWidth, textheigt)]; |
| 207 | self.textLayer.contentsScale = [UIScreen mainScreen].scale; | 208 | self.textLayer.contentsScale = [UIScreen mainScreen].scale; |
| 208 | 209 | ||
| @@ -210,7 +211,7 @@ | @@ -210,7 +211,7 @@ | ||
| 210 | 211 | ||
| 211 | - (void)setIsNegative:(BOOL)isNegative{ | 212 | - (void)setIsNegative:(BOOL)isNegative{ |
| 212 | if (isNegative) { | 213 | if (isNegative) { |
| 213 | - [self.textLayer setString:[[NSString alloc]initWithFormat:@"-%0.f",_grade*100]]; | 214 | + [self.textLayer setString:[[NSString alloc]initWithFormat:@"-%0.f",_grade*self.maxDivisor]]; |
| 214 | CABasicAnimation* rotationAnimation; | 215 | CABasicAnimation* rotationAnimation; |
| 215 | rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; | 216 | rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; |
| 216 | rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI]; | 217 | rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI]; |
| @@ -233,7 +233,7 @@ | @@ -233,7 +233,7 @@ | ||
| 233 | bar.barColor = [self barColorAtIndex:index]; | 233 | bar.barColor = [self barColorAtIndex:index]; |
| 234 | } | 234 | } |
| 235 | // Add gradient | 235 | // Add gradient |
| 236 | - bar.barColorGradientStart = _barColorGradientStart; | 236 | + bar.barColorGradientStart = bar.barColor; |
| 237 | 237 | ||
| 238 | //For Click Index | 238 | //For Click Index |
| 239 | bar.tag = index; | 239 | bar.tag = index; |
| @@ -250,8 +250,9 @@ | @@ -250,8 +250,9 @@ | ||
| 250 | if (isnan(grade)) { | 250 | if (isnan(grade)) { |
| 251 | grade = 0; | 251 | grade = 0; |
| 252 | } | 252 | } |
| 253 | + bar.maxDivisor = (float)_yValueMax; | ||
| 253 | bar.grade = grade; | 254 | bar.grade = grade; |
| 254 | - CGRect originalFrame = bar.frame; | 255 | + CGRect originalFrame = bar.frame; |
| 255 | if (value<0 && self.showLevelLine) { | 256 | if (value<0 && self.showLevelLine) { |
| 256 | CGAffineTransform transform =CGAffineTransformMakeRotation(M_PI); | 257 | CGAffineTransform transform =CGAffineTransformMakeRotation(M_PI); |
| 257 | [bar setTransform:transform]; | 258 | [bar setTransform:transform]; |
| @@ -107,14 +107,14 @@ | @@ -107,14 +107,14 @@ | ||
| 107 | self.barChart.rotateForXAxisText = true ; | 107 | self.barChart.rotateForXAxisText = true ; |
| 108 | 108 | ||
| 109 | self.barChart.yLabelSum=5; | 109 | self.barChart.yLabelSum=5; |
| 110 | - self.barChart.yMaxValue=100; | 110 | + self.barChart.yValueMax=10; |
| 111 | self.barChart.yLabels = @[@-10,@0,@10]; | 111 | self.barChart.yLabels = @[@-10,@0,@10]; |
| 112 | - [self.barChart setYValues:@[@1,@24,@(0-12),@18]]; | 112 | + [self.barChart setYValues:@[@1,@5,@(0-8),@10]]; |
| 113 | 113 | ||
| 114 | - [self.barChart setStrokeColors:@[PNGreen,PNGreen,PNRed,PNGreen,PNGreen,PNYellow,PNGreen]]; | 114 | + [self.barChart setStrokeColors:@[PNGreen,PNGreen,PNRed,PNGreen]]; |
| 115 | // Adding gradient | 115 | // Adding gradient |
| 116 | self.barChart.barColorGradientStart = [UIColor blueColor]; | 116 | self.barChart.barColorGradientStart = [UIColor blueColor]; |
| 117 | - | 117 | + |
| 118 | [self.barChart strokeChart]; | 118 | [self.barChart strokeChart]; |
| 119 | 119 | ||
| 120 | self.barChart.delegate = self; | 120 | self.barChart.delegate = self; |
-
Please register or login to post a comment