stackOffsetSilhouette function Stack offsets Stacks

void stackOffsetSilhouette(
  1. List<List<List<num>>> series,
  2. List<int> order
)

Shifts the baseline down such that the center of the streamgraph is always at zero.

final stack = Stack(…)..offset = stackOffsetSilhouette;

Implementation

void stackOffsetSilhouette(List<List<List<num>>> series, List<int> order) {
  int n;
  if (!((n = series.length) > 0)) return;
  num y0, y;
  for (var j = 0, s0 = series[order[0]], m = s0.length; j < m; ++j) {
    y = 0;
    for (var i = 0; i < n; ++i) {
      y0 = series[i][j][1];
      if (y0.isFinite) y += y0;
    }
    s0[j][1] += s0[j][0] = -y / 2;
  }
  stackOffsetNone(series, order);
}