lerpTo method

  1. @override
ISparklinesData lerpTo(
  1. ISparklinesData next,
  2. double t
)
override

Interpolate between this and next using interpolation factor t (0.0 to 1.0)

Implementation

@override
ISparklinesData lerpTo(ISparklinesData next, double t) {
  if (next is! BarData) return next;
  if (bars.length != next.bars.length) return next;
  if (visible != next.visible) return next;

  final interpolatedBars = <DataPoint>[];
  for (int i = 0; i < bars.length; i++) {
    interpolatedBars.add(bars[i].lerpTo(next.bars[i], t));
  }

  return BarData(
    visible: next.visible,
    rotation: next.rotation,
    flip: next.flip,
    origin: Offset.lerp(origin, next.origin, t) ?? next.origin,
    layout: next.layout,
    crop: next.crop,
    bars: interpolatedBars,
    thickness: thickness.lerpTo(next.thickness, t),
    border: ILerpTo.lerp(border, next.border, t),
    borderRadius: lerpDouble(borderRadius, next.borderRadius, t) ?? next.borderRadius,
    pointStyle: ILerpTo.lerp<IDataPointData>(pointStyle, next.pointStyle, t) as IDataPointStyle?,
  );
}