Open IDOKN opened 7 years ago
(void)updateChartData:(NSArray *)data { _chartData = data;
[self prepareYLabelsWithData:data];
[self calculateChartPath:_chartPath andPointsPath:_pointPath andPathKeyPoints:_pathPoints andPathStartEndPoints:_endPointsOfPath andProgressLinePathsColors:_progressLinePathsColors];
for (NSUInteger lineIndex = 0; lineIndex < self.chartData.count; lineIndex++) {
NSArray<CAShapeLayer *> *chartLines = self.chartLineArray[lineIndex]; CAShapeLayer *pointLayer = (CAShapeLayer *) self.chartPointArray[lineIndex]; NSArray<UIBezierPath *> *progressLines = _chartPath[lineIndex]; UIBezierPath *pointPath = _pointPath[lineIndex]; NSUInteger progressLineIndex = 0; for(UIBezierPath *progressLine in progressLines) { CAShapeLayer *chartLine = chartLines[progressLineIndex]; CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"path"]; pathAnimation.fromValue = (id) chartLine.path; pathAnimation.toValue = (__bridge id) [progressLine CGPath]; pathAnimation.duration = 0.5f; pathAnimation.autoreverses = NO; pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; [chartLine addAnimation:pathAnimation forKey:@"animationKey"]; chartLine.path = progressLine.CGPath; progressLineIndex++; } CABasicAnimation *pointPathAnimation = [CABasicAnimation animationWithKeyPath:@"path"]; pointPathAnimation.fromValue = (id) pointLayer.path; pointPathAnimation.toValue = (__bridge id) [pointPath CGPath]; pointPathAnimation.duration = 0.5f; pointPathAnimation.autoreverses = NO; pointPathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; [pointLayer addAnimation:pointPathAnimation forKey:@"animationKey"]; pointLayer.path = pointPath.CGPath;
}
您好,更新数据之后,之前的数据还存在,这是什么原因呀
赞一个
(void)updateChartData:(NSArray *)data { _chartData = data;
[self prepareYLabelsWithData:data];
[self calculateChartPath:_chartPath andPointsPath:_pointPath andPathKeyPoints:_pathPoints andPathStartEndPoints:_endPointsOfPath andProgressLinePathsColors:_progressLinePathsColors];
for (NSUInteger lineIndex = 0; lineIndex < self.chartData.count; lineIndex++) {
}