kevinzhow

Change path

@@ -502,6 +502,40 @@ @@ -502,6 +502,40 @@
502 502
503 - (void)updateChartData:(NSArray *)data 503 - (void)updateChartData:(NSArray *)data
504 { 504 {
  505 + _chartData = data;
  506 +
  507 + [self calculateChartPath:_chartPath andPointsPath:_pointPath andPathKeyPoints:_pathPoints];
  508 +
  509 + for (NSUInteger lineIndex = 0; lineIndex < self.chartData.count; lineIndex++) {
  510 +
  511 + CAShapeLayer *chartLine = (CAShapeLayer *)self.chartLineArray[lineIndex];
  512 + CAShapeLayer *pointLayer = (CAShapeLayer *)self.chartPointArray[lineIndex];
  513 +
  514 +
  515 + UIBezierPath *progressline = [_chartPath objectAtIndex:lineIndex];
  516 + UIBezierPath *pointPath = [_pointPath objectAtIndex:lineIndex];
  517 +
  518 +
  519 + CABasicAnimation * pathAnimation = [CABasicAnimation animationWithKeyPath:@"path"];
  520 + pathAnimation.toValue = (id)[progressline CGPath];
  521 + pathAnimation.duration = 0.5f;
  522 + pathAnimation.autoreverses = NO;
  523 + pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
  524 + [chartLine addAnimation:pathAnimation forKey:@"animationKey"];
  525 +
  526 +
  527 + CABasicAnimation * pointPathAnimation = [CABasicAnimation animationWithKeyPath:@"path"];
  528 + pointPathAnimation.toValue = (id)[pointPath CGPath];
  529 + pointPathAnimation.duration = 0.5f;
  530 + pointPathAnimation.autoreverses = NO;
  531 + pointPathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
  532 + [pointLayer addAnimation:pointPathAnimation forKey:@"animationKey"];
  533 +
  534 + chartLine.path = progressline.CGPath;
  535 + pointLayer.path = pointPath.CGPath;
  536 +
  537 +
  538 + }
505 539
506 } 540 }
507 541