public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. SFTreeMap treeMap = new SFTreeMap(); treeMap.WeightValuePath = (NSString)"Population"; treeMap.ColorValuePath = (NSString)"Growth"; SFLeafItemSetting leafItemSetting = new SFLeafItemSetting(); leafItemSetting.Gap = 2; leafItemSetting.LabelPath = (NSString)"Region"; leafItemSetting.BorderColor = UIColor.FromRGB(169, 217, 247); leafItemSetting.ShowLabels = true; treeMap.LeafItemSettings = leafItemSetting; SFTreeMapFlatLevel flatLevel = new SFTreeMapFlatLevel(); flatLevel.GroupBorderColor = UIColor.Gray; flatLevel.GroupBorderWidth = 1; flatLevel.GroupBackground = UIColor.White; flatLevel.HeaderHeight = 20; flatLevel.GroupPath = (NSString)"Continent"; flatLevel.GroupGap = 5; flatLevel.HeaderStyle = new SFStyle() { Color = UIColor.Black }; flatLevel.ShowHeader = true; treeMap.Levels.Add(flatLevel); SFLegendSetting legendSetting = new SFLegendSetting(); legendSetting.ShowLegend = true; legendSetting.Size = new CoreGraphics.CGSize(500, 45); treeMap.LegendSettings = legendSetting; SFRangeColorMapping colorMapping = new SFRangeColorMapping(); SFRange range1 = new SFRange(); range1.LegendLabel = (NSString)"1 % Growth"; range1.From = 0; range1.To = 1; range1.Color = UIColor.FromRGB(119, 216, 216); SFRange range2 = new SFRange(); range2.LegendLabel = (NSString)"2 % Growth"; range2.From = 0; range2.To = 2; range2.Color = UIColor.FromRGB(174, 217, 96); SFRange range3 = new SFRange(); range3.LegendLabel = (NSString)"3 % Growth"; range3.From = 0; range3.To = 3; range3.Color = UIColor.FromRGB(255, 175, 81); SFRange range4 = new SFRange(); range4.LegendLabel = (NSString)"4 % Growth"; range4.From = 0; range4.To = 4; range4.Color = UIColor.FromRGB(243, 210, 64); colorMapping.Ranges.Add(range1); colorMapping.Ranges.Add(range2); colorMapping.Ranges.Add(range3); colorMapping.Ranges.Add(range4); treeMap.LeafItemColorMapping = colorMapping; GetPopulationData(); treeMap.DataSource = PopulationDetails; treeMap.ShowTooltip = true; treeMap.Frame = new CoreGraphics.CGRect(View.Frame.Left, View.Frame.Top + 50, View.Frame.Width, View.Frame.Height - 100); this.View.AddSubview(treeMap); }
public TreeMapDrilldown() { view = new UIView(); header = new UILabel(); header.TextAlignment = UITextAlignment.Center; header.Text = "Continents by population"; header.Font = UIFont.SystemFontOfSize(18); header.Frame = new CGRect(0, 0, 400, 40); header.TextColor = UIColor.Black; view.AddSubview(header); treeMap = new SFTreeMap(); treeMap.WeightValuePath = (NSString)"Population"; treeMap.ColorValuePath = (NSString)"Population"; SFLeafItemSetting leafItemSetting = new SFLeafItemSetting(); leafItemSetting.Gap = 2; leafItemSetting.LabelPath = (NSString)"Region"; leafItemSetting.BorderColor = UIColor.FromRGB(169, 217, 247); leafItemSetting.ShowLabels = true; treeMap.LeafItemSettings = leafItemSetting; SFTreeMapFlatLevel flatLevel = new SFTreeMapFlatLevel(); flatLevel.GroupBackground = UIColor.White; flatLevel.HeaderHeight = 20; flatLevel.GroupPath = (NSString)"Continent"; flatLevel.GroupGap = 5; flatLevel.HeaderStyle = new SFStyle() { Color = UIColor.Black }; flatLevel.LabelPath = (NSString)"Continent"; flatLevel.ShowHeader = true; treeMap.Levels.Add(flatLevel); SFTreeMapFlatLevel flatLevel1 = new SFTreeMapFlatLevel(); flatLevel1.GroupBackground = UIColor.White; flatLevel1.HeaderHeight = 20; flatLevel1.HeaderStyle = new SFStyle() { Color = UIColor.Black }; flatLevel1.GroupPath = (NSString)"States"; flatLevel1.LabelPath = (NSString)"States"; flatLevel1.GroupGap = 5; flatLevel1.ShowHeader = true; treeMap.Levels.Add(flatLevel1); SFPaletteColorMapping colorMapping = new SFPaletteColorMapping(); colorMapping.Colors.Add(UIColor.FromRGB(192, 68, 165)); colorMapping.Colors.Add(UIColor.FromRGB(102, 81, 151)); colorMapping.Colors.Add(UIColor.FromRGB(255, 70, 82)); colorMapping.Colors.Add(UIColor.FromRGB(139, 34, 134)); colorMapping.Colors.Add(UIColor.FromRGB(68, 143, 192)); treeMap.LeafItemColorMapping = colorMapping; treeMap.EnableDrilldown = true; GetPopulationData(); treeMap.DataSource = PopulationDetails; treeMap.ShowTooltip = true; view.AddSubview(treeMap); AddSubview(view); }