onLayout method
Implementation
@override
void onLayout(double left, double top, double right, double bottom) {
double topMargin = 0;
double leftMargin = 0;
double rightMargin = 0;
double bottomMargin = 0;
_xMap.forEach((key, value) {
if (Align2.start == value.axis.position) {
topMargin = max(topMargin, value.axisSize.rect.height);
} else {
bottomMargin = max(bottomMargin, value.axisSize.rect.height);
}
});
_yMap.forEach((key, value) {
if (Align2.end == value.axis.position) {
rightMargin = max(rightMargin, value.axisSize.rect.width);
} else {
leftMargin = max(leftMargin, value.axisSize.rect.width);
}
});
_xMap.forEach((key, value) {
List<DynamicData> dl = [];
for (var ele in value.children) {
dl.addAll(ele.xDataSet);
}
LineProps layoutProps;
if (value.axis.position == Align2.start) {
Offset start = Offset(leftMargin, topMargin);
Offset end = Offset(width - rightMargin, topMargin);
layoutProps = LineProps(Rect.zero, start, end);
} else {
Offset start = Offset(leftMargin, height - bottomMargin);
Offset end = Offset(width - rightMargin, height - bottomMargin);
layoutProps = LineProps(Rect.zero, start, end);
}
value.layout(layoutProps, dl);
});
_yMap.forEach((key, value) {
List<DynamicData> dl = [];
for (var ele in value.children) {
dl.addAll(ele.yDataSet);
}
LineProps layoutProps;
if (value.axis.position == Align2.end) {
Offset start = Offset(width - rightMargin, topMargin);
Offset end = Offset(width - rightMargin, height - bottomMargin);
layoutProps = LineProps(Rect.zero, start, end);
} else {
Offset start = Offset(0, topMargin);
Offset end = Offset(0, height - bottomMargin);
layoutProps = LineProps(Rect.zero, start, end);
}
value.layout(layoutProps, dl);
});
for (var element in children) {
element.layout(leftMargin, topMargin, element.width - rightMargin, element.height - bottomMargin);
}
}