public double AspectRatio(List <TreemapData> items) { double area = Area(items.Last().Size); if (Empty.IsHorizontal()) { double width = Area(items) / Empty.Height; return(new Rect(0, 0, area / width, width).AspectRatio()); } else { double height = Area(items) / Empty.Width; return(new Rect(0, 0, height, area / height).AspectRatio()); } }
public void AddItems(List <TreemapData> items) { double top = Empty.Top; double left = Empty.Left; if (Empty.IsHorizontal()) { double width = Area(items) / Empty.Height; foreach (TreemapData data in items) { double area = Area(data.Size); Items.Add(new TreemapItem(left, top, width, area / width) { Indexes = data.Indexes, Size = data.Size, Color = data.Color }); top += area / width; } Empty = new Rect(Empty.Left + width, Empty.Top, (Empty.Width - width).Floor(0), Empty.Height); } else { double height = Area(items) / Empty.Width; foreach (TreemapData data in items) { double area = Area(data.Size); Items.Add(new TreemapItem(left, top, area / height, height) { Indexes = data.Indexes, Size = data.Size, Color = data.Color }); left += area / height; } Empty = new Rect(Empty.Left, Empty.Top + height, Empty.Width, (Empty.Height - height).Floor(0)); } }