layoutChildren static method

void layoutChildren(
  1. Rect rect,
  2. List<TreeMapNode> nodeList
)

从上到下

Implementation

static void layoutChildren(Rect rect, List<TreeMapNode> nodeList) {
  double w = rect.width;
  double h = rect.height;
  double allValue = computeAllRatio(nodeList);
  double topOffset = rect.top;
  for (var node in nodeList) {
    double ratio = node.areaRatio / allValue;
    double h2 = ratio * h;
    node.position = Rect.fromLTWH(rect.left, topOffset, w, h2);
    topOffset += node.position.height;
  }
}