measureAxisNameTextMaxSize function
给定坐标轴集和方向 测量单个坐标轴名占用的最大宽度和高度 当 对齐为 center时 直接返回0
Implementation
List<Size> measureAxisNameTextMaxSize(Iterable<BaseAxis> axisList, Direction direction, num maxWidth) {
Size firstSize = Size.zero;
Size lastSize = Size.zero;
for (var axis in axisList) {
if (axis.nameAlign == Align2.center) {
continue;
}
Size size = axis.nameStyle.measure(axis.name, maxWidth: maxWidth.toDouble());
double mw;
double mh;
if (direction == Direction.horizontal) {
mw = math.max(firstSize.width, size.width);
mh = math.max(firstSize.height, size.height + axis.nameGap);
} else {
mw = math.max(firstSize.width, size.width + axis.nameGap);
mh = math.max(firstSize.height, size.height);
}
if (axis.nameAlign == Align2.start) {
firstSize = Size(mw, mh);
} else {
lastSize = Size(mw, mh);
}
}
return [firstSize, lastSize];
}