modify method
AttributesGroups
modify(
- AttributesGroups groups,
- Map<
String, ScaleConv< scales,dynamic, num> > - AlgForm form,
- CoordConv coord,
- Offset origin,
override
Modifies the position of mark items.
The aesthetic encodes are in the groups
.
Note that the modifier should be functional, which means to return a new groups list as result, not to change the input groups.
Implementation
@override
AttributesGroups modify(
AttributesGroups groups,
Map<String, ScaleConv<dynamic, num>> scales,
AlgForm form,
CoordConv coord,
Offset origin) {
final normalZero = origin.dy;
final AttributesGroups rst = groups.map((_) => <Attributes>[]).toList();
for (var i = 0; i < groups.first.length; i++) {
var minY = double.infinity;
var maxY = double.negativeInfinity;
for (var group in groups) {
final attributes = group[i];
for (var point in attributes.position) {
final y = point.dy;
if (y.isFinite) {
minY = min(minY, y);
maxY = max(maxY, y);
}
}
}
final symmetricBias = normalZero - (minY + maxY) / 2;
for (var j = 0; j < groups.length; j++) {
final attributes = groups[j][i];
final oldPosition = attributes.position;
rst[j].add(attributes.withPosition(oldPosition
.map(
(point) => Offset(point.dx, point.dy + symmetricBias),
)
.toList()));
}
}
return rst;
}