Emma Makinson

Makes animation optional on Radar chart

@@ -202,26 +202,8 @@ @@ -202,26 +202,8 @@
202 [plotline setLineCapStyle:kCGLineCapButt]; 202 [plotline setLineCapStyle:kCGLineCapButt];
203 203
204 _chartPlot.path = plotline.CGPath; 204 _chartPlot.path = plotline.CGPath;
205 - 205 +
206 - CABasicAnimation *animateScale = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; 206 + [self addAnimationIfNeeded];
207 - animateScale.fromValue = [NSNumber numberWithFloat:0.f];  
208 - animateScale.toValue = [NSNumber numberWithFloat:1.0f];  
209 -  
210 - CABasicAnimation *animateMove = [CABasicAnimation animationWithKeyPath:@"position"];  
211 - animateMove.fromValue = [NSValue valueWithCGPoint:CGPointMake(_centerX, _centerY)];  
212 - animateMove.toValue = [NSValue valueWithCGPoint:CGPointMake(0, 0)];  
213 -  
214 - CABasicAnimation *animateAlpha = [CABasicAnimation animationWithKeyPath:@"opacity"];  
215 - animateAlpha.fromValue = [NSNumber numberWithFloat:0.f];  
216 -  
217 - CAAnimationGroup *aniGroup = [CAAnimationGroup animation];  
218 - aniGroup.duration = 1.f;  
219 - aniGroup.repeatCount = 1;  
220 - aniGroup.animations = [NSArray arrayWithObjects:animateScale,animateMove,animateAlpha, nil];  
221 - aniGroup.removedOnCompletion = YES;  
222 -  
223 - [_chartPlot addAnimation:aniGroup forKey:nil];  
224 -  
225 [self showGraduation]; 207 [self showGraduation];
226 } 208 }
227 209
@@ -363,6 +345,28 @@ @@ -363,6 +345,28 @@
363 return ceil(max); 345 return ceil(max);
364 } 346 }
365 347
366 - 348 +- (void)addAnimationIfNeeded
  349 +{
  350 + if (self.displayAnimated) {
  351 + CABasicAnimation *animateScale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
  352 + animateScale.fromValue = [NSNumber numberWithFloat:0.f];
  353 + animateScale.toValue = [NSNumber numberWithFloat:1.0f];
  354 +
  355 + CABasicAnimation *animateMove = [CABasicAnimation animationWithKeyPath:@"position"];
  356 + animateMove.fromValue = [NSValue valueWithCGPoint:CGPointMake(_centerX, _centerY)];
  357 + animateMove.toValue = [NSValue valueWithCGPoint:CGPointMake(0, 0)];
  358 +
  359 + CABasicAnimation *animateAlpha = [CABasicAnimation animationWithKeyPath:@"opacity"];
  360 + animateAlpha.fromValue = [NSNumber numberWithFloat:0.f];
  361 +
  362 + CAAnimationGroup *aniGroup = [CAAnimationGroup animation];
  363 + aniGroup.duration = 1.f;
  364 + aniGroup.repeatCount = 1;
  365 + aniGroup.animations = [NSArray arrayWithObjects:animateScale,animateMove,animateAlpha, nil];
  366 + aniGroup.removedOnCompletion = YES;
  367 +
  368 + [_chartPlot addAnimation:aniGroup forKey:nil];
  369 + }
  370 +}
367 371
368 @end 372 @end