BubbleChart constructor

BubbleChart(
  1. {required BubbleNode root,
  2. required Size size,
  3. double radius(
    1. BubbleNode
    )?,
  4. double stretchFactor = 1.0}
)

Implementation

BubbleChart({
  required this.root,
  required this.size,
  this.radius,
  this.stretchFactor = 1.0,
})  : assert(root.children != null && root.children!.isNotEmpty),
      assert(size.width > 0 && size.height > 0) {
  root.x = size.width / 2;
  root.y = size.height / 2;

  if (radius != null) {
    root
      ..leaves.forEach(_radiusLeaf(radius))
      ..eachAfter(_packChildren(0.5))
      ..eachBefore(_translateChild(1));
  } else {
    root
      ..leaves.forEach(_radiusLeaf(_defaultRadius))
      ..eachAfter(_packChildren(1, 0))
      ..eachAfter(_packChildren(root.radius! / min(size.width, size.height)))
      ..eachBefore(
          _translateChild(min(size.width, size.height) / (2 * root.radius!)));
  }
}