modify method

  1. @override
void modify(
  1. AesGroups groups,
  2. Map<String, ScaleConv<dynamic, num>> scales,
  3. AlgForm form,
  4. CoordConv coord,
  5. Offset origin,
)
override

Modifies the position of element items.

The aesthetic attributes are in the groups.

Implementation

@override
void modify(AesGroups groups, Map<String, ScaleConv<dynamic, num>> scales,
    AlgForm form, CoordConv coord, Offset origin) {
  final xField = form.first[0];
  final band = (scales[xField] as DiscreteScaleConv).band;

  final ratio = this.ratio ?? 1 / (groups.length);
  final symmetric = this.symmetric ?? true;

  final bias = ratio * band;
  // If symmetric, negtively shifts half of the total bias.
  var accumulated = symmetric ? -bias * (groups.length - 1) / 2 : 0.0;

  for (var group in groups) {
    for (var aes in group) {
      final oldPosition = aes.position;
      aes.position = oldPosition
          .map(
            (point) => Offset(point.dx + accumulated, point.dy),
          )
          .toList();
    }
    accumulated += bias;
  }
}