copyOldSegmentValues method
void
copyOldSegmentValues()
override
Implementation
@override
void copyOldSegmentValues(
double seriesAnimationFactor, double segmentAnimationFactor) {
if (series.animationType == AnimationType.loading) {
points.clear();
_oldSegmentRect = null;
_oldPoints.clear();
return;
}
if (series.animationDuration > 0) {
if (points.isEmpty) {
_oldPoints.clear();
return;
}
final int newPointsLength = points.length;
final int oldPointsLength = _oldPoints.length;
if (oldPointsLength == newPointsLength) {
for (int i = 0; i < newPointsLength; i++) {
_oldPoints[i] =
Offset.lerp(_oldPoints[i], points[i], segmentAnimationFactor)!;
}
} else {
final int minLength = min(oldPointsLength, newPointsLength);
for (int i = 0; i < minLength; i++) {
_oldPoints[i] =
Offset.lerp(_oldPoints[i], points[i], segmentAnimationFactor)!;
}
if (newPointsLength > oldPointsLength) {
_oldPoints.addAll(points.sublist(oldPointsLength));
} else {
_oldPoints.removeRange(minLength, oldPointsLength);
}
}
_oldSegmentRect =
RRect.lerp(_oldSegmentRect, segmentRect, segmentAnimationFactor);
} else {
_oldPoints.clear();
_oldSegmentRect = segmentRect;
}
}