morphTo method

void morphTo(
  1. double t
)

A morph's progress, 0 to 1: each point of the new line is drawn between where the old line was above it and where it belongs.

Implementation

void morphTo(double t) {
  final target = _target, mark = _morphMark;
  if (target == null) return;
  if (t >= 1 || mark == null || _morphFrom == null) {
    rows = target;
    _target = null;
    _morphFrom = null;
    _changed();
    return;
  }
  final (pane, m) = mark;
  _domains.clear();
  final (lo, hi) = yDomain(pane);
  rows = [
    for (var i = 0; i < target.length; i++)
      if (target[i][m.valueField] case final num v)
        {
          ...target[i],
          m.valueField: () {
            final was = _morphHeightAt((xOfRow(i) - plotLeft) / plotWidth), now = (v - lo) / (hi - lo);
            return lo + (was + (now - was) * t) * (hi - lo);
          }(),
        }
      else
        target[i],
  ];
  _changed();
}