public void Squarify(List <TreemapData> data) { for (int i = 0; i < data.Count; i++) { int n = 1; double aspectRatio = AspectRatio(data.GetRange(i, n)); double nextAspectRatio = aspectRatio; while (nextAspectRatio <= aspectRatio && !Empty.IsDegenerated()) { n++; if (data.Count < i + n) { break; } aspectRatio = nextAspectRatio; nextAspectRatio = AspectRatio(data.GetRange(i, n)); } n--; AddItems(data.GetRange(i, n)); i += n - 1; if (Empty.IsDegenerated()) { break; } } }