setData method
New rows. Told apart by the spec's key: rows after the last one known are followed (a view at the end) or left off screen (a view back in history); older rows put before move nothing; a row with a known key is an update in place.
With tween (and a spec that animates), the marks move from the
values on screen to the new ones as tweenTo is turned from 0 to 1,
rows told apart by the spec's key (a row not there before grows from
zero).
Implementation
void setData(List<Json> data, {bool tween = false}) {
final key = spec.key;
final lastKey = count == 0 ? null : rows.last[key];
final firstKey = count == 0 ? null : rows.first[key];
final before = tween && spec.animate > 0 && plotWidth > 0 ? {for (final r in rows) r[key]: r} : null;
_tweenFrom = _tweenTo = null;
_source = data;
rows = applyGraphTransforms(data, spec.transforms);
if (lastKey != null) {
final at = rows.lastIndexWhere((r) => r[key] == lastKey);
if (at < 0) {
viewport = GraphViewport(barSpacing: spec.x.barSpacing, rightOffset: spec.x.rightOffset);
} else {
viewport = viewport.afterAppend(count - 1 - at, follow: spec.x.follow == 'end');
}
}
// Older rows have come (or the rows are other rows altogether): the
// graph may ask again. A new row at the end answers nothing, so a
// request under way is not sent twice.
if (count == 0 || rows.first[key] != firstKey) _askedHistory = false;
if (_morphFrom != null && count > 0 && plotWidth > 0) {
_target = rows;
_settle();
morphTo(0);
return;
}
_morphFrom = null;
if (before != null && count > 0) {
_tweenFrom = before;
_tweenTo = rows;
_settle();
tweenTo(0);
return;
}
_settle();
}