public override View GetSampleContent(Context context)
        {
            tree = new SfTreeMap(context);
            tree.WeightValuePath = "Population";
            tree.ColorValuePath = "Growth";
            tree.HighlightOnSelection = false;
            var margin = context.Resources.DisplayMetrics.Density * 20;
            float density = context.Resources.DisplayMetrics.Density;

            //LeafItemSetting
            tree.LeafItemSettings = new LeafItemSetting() { ShowLabels = true, Gap = 5, LabelPath = "Region", StrokeColor = Color.White, StrokeWidth = 2 };
            tree.LeafItemSettings.LabelStyle = new Style() { Margin = new Margin(margin / 2, margin, 0, 0), TextSize = 18, TextColor = Color.White };

            TreeMapFlatLevel level = new TreeMapFlatLevel { ShowHeader = true, GroupPath = "Continent", GroupStrokeColor = Color.Gray, GroupStrokeWidth = 1, GroupPadding = 5, HeaderHeight = 25 };
            level.HeaderStyle = new Style() { TextColor = Color.Gray, TextSize = 16 };

            tree.Levels.Add(level);

            //RangeColorMapping
            List<Range> ranges = new List<Range>();
            ranges.Add(new Range() { LegendLabel = "1 % Growth", From = 0, To = 1, Color = Color.ParseColor("#77D8D8") });
            ranges.Add(new Range() { LegendLabel = "2 % Growth", From = 0, To = 2, Color = Color.ParseColor("#AED960") });
            ranges.Add(new Range() { LegendLabel = "3 % Growth", From = 0, To = 3, Color = Color.ParseColor("#FFAF51") });
            ranges.Add(new Range() { LegendLabel = "4 % Growth", From = 0, To = 4, Color = Color.ParseColor("#F3D240") });
            tree.LeafItemColorMapping = new RangeColorMapping() { Ranges = ranges };

            //LegendSetting
            Size legendSize = new Size(300, 100);
            Size iconSize = new Size(12, 12);
            Color legendColor = Color.Gray;
            tree.LegendSettings = new LegendSetting()
            {
                LabelStyle = new Style()
                {
                    TextSize = 12,
                    TextColor = legendColor
                },
                IconSize = iconSize,
                ShowLegend = true,
                LegendSize = legendSize
            };
            tree.ShowTooltip = true;
            CustomTooltipSetting tooltip = new CustomTooltipSetting(context);
            tree.TooltipSettings = tooltip;
            tree.DataSource = GetDataSource();
            return tree;
        }
示例#2
0
        public Form1()
        {
            InitializeComponent();
            this.MetroColor = Color.White;
            this.BackColor  = Color.White;

            PopulationViewModel data = new PopulationViewModel();

            TreeMap1.ItemsSource                  = data.PopulationDetails;
            TreeMap1.WeightValuePath              = "Population";
            TreeMap1.ColorValuePath               = "Growth";
            TreeMap1.LegendSetting.LegendType     = LegendTypes.Ellipse;
            TreeMap1.LegendSetting.LegendGap      = 150;
            TreeMap1.LegendSetting.ShowLegend     = true;
            TreeMap1.LegendSetting.LegendPosition = LegendPositions.Top;
            TreeMap1.Dock = DockStyle.Fill;
            //TreeMap1.Margin = new System.Windows.Forms.Padding(10,10,10,10);
            TreeMap1.ItemsLayoutMode = Syncfusion.Windows.Forms.TreeMap.ItemsLayoutModes.SliceAndDiceAuto;
            ToolTipInfo itemInfoHead = new ToolTipInfo();

            itemInfoHead.ToolTipHeaderPattern  = "<b>{Label}</b>";
            itemInfoHead.ToolTipContentPattern = "Growth \t  :  {Growth} % ";
            TreeMap1.HeaderToolTipInfo         = itemInfoHead;
            ToolTipInfo itemInfo = new ToolTipInfo();

            itemInfo.ToolTipHeaderPattern  = "<b>{Country}</b>";
            itemInfo.ToolTipContentPattern = "Growth \t      :  {Growth} %  \nPopulation   :  {StrPopulation}  ";
            TreeMap1.ItemToolTipInfo       = itemInfo;

            #region ColorMapping

            #region Range ColorMapping

            //RangeBrushColorMapping
            RangeBrushColorMapping rangeBrushColorMapping = new RangeBrushColorMapping();
            rangeBrushColorMapping.Brushes.Add(new RangeBrush()
            {
                Color = System.Drawing.ColorTranslator.FromHtml("#77D8D8"), From = 0, To = 1, LegendLabel = "1% Growth"
            });
            rangeBrushColorMapping.Brushes.Add(new RangeBrush()
            {
                Color = System.Drawing.ColorTranslator.FromHtml("#AED960"), From = 0, To = 2, LegendLabel = "2% Growth"
            });
            rangeBrushColorMapping.Brushes.Add(new RangeBrush()
            {
                Color = System.Drawing.ColorTranslator.FromHtml("#FFAF51"), From = 0, To = 3, LegendLabel = "3% Growth"
            });
            rangeBrushColorMapping.Brushes.Add(new RangeBrush()
            {
                Color = System.Drawing.ColorTranslator.FromHtml("#F3D240"), From = 0, To = 4, LegendLabel = "4% Growth"
            });
            TreeMap1.LeafColorMapping = rangeBrushColorMapping;

            #endregion

            #endregion

            #region Level

            //Level

            TreeMapFlatLevel treeMapFlatLevel1 = new TreeMapFlatLevel();
            treeMapFlatLevel1.GroupPath = "Continent";
            TreeMap1.Levels.Add(treeMapFlatLevel1);

            TreeMap1.LeafItemSettings.LabelPath = "Country";
            TreeMap1.LeafItemDrawing           += TreeMap1_LeafItemDrawing;
            #endregion

            LegendPositionComboBox.Items.Add("Left");
            LegendPositionComboBox.Items.Add("Right");
            LegendPositionComboBox.Items.Add("Top");
            LegendPositionComboBox.Items.Add("Bottom");
            LegendPositionComboBox.SelectedIndex         = 2;
            LegendPositionComboBox.KeyDown              += LegendPositionComboBox_KeyDown;
            LegendPositionComboBox.Dock                  = DockStyle.Top;
            LegendPositionComboBox.Font                  = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            LegendPositionComboBox.SelectedValueChanged += comboBox1_SelectedValueChanged;
            userOptionsGroupBox.Controls.Add(LegendPositionComboBox);

            legendpositionLabel.Text   = "Legend Position :";
            legendpositionLabel.Height = (int)DpiAware.LogicalToDeviceUnits(legendpositionLabel.Height);
            legendpositionLabel.Dock   = DockStyle.Top;
            legendpositionLabel.Font   = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            userOptionsGroupBox.Controls.Add(legendpositionLabel);

            splitter.Dock   = DockStyle.Top;
            splitter.Height = 40;
            userOptionsGroupBox.Controls.Add(splitter);

            layoutModeComboBox.Items.Add("SliceAndDiceAuto");
            layoutModeComboBox.Items.Add("SliceAndDiceHorizontal");
            layoutModeComboBox.Items.Add("SliceAndDiceVertical");
            layoutModeComboBox.Items.Add("Squarified");
            layoutModeComboBox.SelectedIndex         = 0;
            layoutModeComboBox.KeyDown              += layoutModeComboBox_KeyDown;
            layoutModeComboBox.Dock                  = DockStyle.Top;
            layoutModeComboBox.Font                  = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            layoutModeComboBox.SelectedValueChanged += layoutModeComboBox_SelectedValueChanged;
            userOptionsGroupBox.Controls.Add(layoutModeComboBox);

            layoutModeLabel.Text   = "TreeMap Layout :";
            layoutModeLabel.Height = (int)DpiAware.LogicalToDeviceUnits(layoutModeLabel.Height);
            layoutModeLabel.Font   = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            layoutModeLabel.Dock   = DockStyle.Top;
            userOptionsGroupBox.Controls.Add(layoutModeLabel);
            userOptionsGroupBox.Dock  = DockStyle.Right;
            userOptionsGroupBox.Width = (int)DpiAware.LogicalToDeviceUnits(userOptionsGroupBox.Width);

            treeMapContainer.Name = "Population Growth FY2012";
            treeMapPanel.Dock     = DockStyle.Fill;
            treeMapPanel.Controls.Add(TreeMap1);
            treeMapPanel.Controls.Add(userOptionsGroupBox);
            this.Controls.Add(treeMapPanel);

            sampleHeader.Text      = "This sample represents various types of layout available in the TreeMap for arrangement of items";
            sampleHeader.Font      = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            sampleHeader.Location  = new Point(10, 10);
            sampleHeader.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(150)))), ((int)(((byte)(205)))));
            sampleHeader.ForeColor = System.Drawing.Color.White;
            sampleHeader.Location  = new System.Drawing.Point(0, 0);
            sampleHeader.Size      = new System.Drawing.Size(284, (int)DpiAware.LogicalToDeviceUnits(33));
            sampleHeader.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            sampleHeader.Dock      = DockStyle.Top;
            this.Controls.Add(sampleHeader);
        }
示例#3
0
        public override View GetSampleContent(Context context)
        {
            DisplayMetrics displayMetrics = context.Resources.DisplayMetrics;
            int            screenHeight   = displayMetrics.HeightPixels;

            LinearLayout layout = new LinearLayout(context);

            layout.Orientation = Orientation.Vertical;

            TextView textView = new TextView(context);

            textView.TextAlignment = TextAlignment.Center;
            textView.TextSize      = 18;
            textView.Gravity       = GravityFlags.CenterHorizontal | GravityFlags.CenterVertical;
            textView.SetHeight((int)(screenHeight * 0.05));
            textView.Text = "Continents by population";
            layout.AddView(textView);

            treeMap = new SfTreeMap(context);
            treeMap.WeightValuePath      = "Population";
            treeMap.ColorValuePath       = "Population";
            treeMap.HighlightOnSelection = false;

            treeMap.LeafItemSettings = new LeafItemSetting()
            {
                ShowLabels  = true,
                Gap         = 5,
                LabelPath   = "Region",
                StrokeColor = Android.Graphics.Color.Gray,
                StrokeWidth = 1
            };

            TreeMapFlatLevel level = new TreeMapFlatLevel
            {
                ShowHeader       = true,
                GroupPath        = "Continent",
                GroupStrokeColor = Android.Graphics.Color.Gray,
                GroupStrokeWidth = 1,
                GroupPadding     = 5,
                LabelPath        = "Continent",
                HeaderStyle      = new Style()
                {
                    TextColor = Android.Graphics.Color.Black
                },
                HeaderHeight = 25
            };


            TreeMapFlatLevel level1 = new TreeMapFlatLevel
            {
                ShowHeader       = true,
                GroupPath        = "States",
                GroupStrokeColor = Android.Graphics.Color.Gray,
                GroupStrokeWidth = 1,
                GroupPadding     = 5,
                LabelPath        = "States",
                HeaderStyle      = new Style()
                {
                    TextColor = Android.Graphics.Color.Black
                },
                HeaderHeight = 25
            };

            treeMap.Levels.Add(level);
            treeMap.Levels.Add(level1);

            PaletteColorMapping colorMapping = new PaletteColorMapping();

            colorMapping.Colors.Add(Color.ParseColor("#C044A5"));
            colorMapping.Colors.Add(Color.ParseColor("#665197"));
            colorMapping.Colors.Add(Color.ParseColor("#FF4652"));
            colorMapping.Colors.Add(Color.ParseColor("#8B2286"));
            colorMapping.Colors.Add(Color.ParseColor("#448FC0"));

            treeMap.LeafItemColorMapping = colorMapping;

            treeMap.DataSource      = GetDataSource();
            treeMap.EnableDrilldown = true;
            treeMap.ShowTooltip     = true;
            layout.AddView(treeMap);
            return(layout);
        }
        public GettingStarted()
        {
            baritem = new ToolbarItem();
            tree    = new SfTreeMap();
            Title   = "GettingStarted";
            this.BackgroundColor              = Device.OnPlatform(iOS: Color.White, Android: Color.White, WinPhone: Color.Black);
            tree.WeightValuePath              = "Population";
            tree.ColorValuePath               = "Growth";
            tree.LeafItemSettings             = new LeafItemSettings();
            tree.LeafItemSettings.BorderColor = Device.OnPlatform(iOS: Color.Gray, Android: Color.White, WinPhone: IsDarkTheme ? Color.White : Color.Gray);
            tree.LeafItemSettings.BorderWidth = Device.OnPlatform(iOS: 1, Android: 2, WinPhone: 2);
            tree.LeafItemSettings.Gap         = Device.OnPlatform(iOS: 1, Android: 5, WinPhone: 3);
            tree.LeafItemSettings.LabelStyle  = new Syncfusion.SfTreeMap.XForms.Style()
            {
                Font = Font.SystemFontOfSize(18), Color = Color.White
            };
            tree.LeafItemSettings.LabelPath = "Country";
            ObservableCollection <Range> ranges = new ObservableCollection <Range>();

            ranges.Add(new Range()
            {
                LegendLabel = "1 % Growth", From = 0, To = 1, Color = Color.FromHex("#77D8D8")
            });
            ranges.Add(new Range()
            {
                LegendLabel = "2 % Growth", From = 0, To = 2, Color = Color.FromHex("#AED960")
            });
            ranges.Add(new Range()
            {
                LegendLabel = "3 % Growth", From = 0, To = 3, Color = Color.FromHex("#FFAF51")
            });
            ranges.Add(new Range()
            {
                LegendLabel = "4 % Growth", From = 0, To = 4, Color = Color.FromHex("#F3D240")
            });
            tree.LeafItemColorMapping = rangeMapping = new RangeColorMapping()
            {
                Ranges = ranges
            };
            Size legendSize = Device.OnPlatform(iOS: new Size(300, 60), Android: new Size(200, 60), WinPhone: new Size(420, 75));
            Size iconSize   = Device.OnPlatform(iOS: new Size(17, 17), Android: new Size(25, 25), WinPhone: new Size(15, 15));


            treeMapColorMapping = rangeMapping;
            desaturationMapping = new DesaturationColorMapping()
            {
                From = 1, To = 0.2, Color = Color.FromHex("#02AEDC")
            };
            TreeMapFlatLevel level = new TreeMapFlatLevel()
            {
                HeaderStyle = new Syncfusion.SfTreeMap.XForms.Style()
                {
                    Color = Device.OnPlatform(iOS: Color.Gray, Android: Color.Gray, WinPhone: Color.White)
                }, GroupPath = "Continent", HeaderHeight = 20, GroupGap = 5, ShowHeader = true
            };

            level.GroupBackground = Device.OnPlatform(iOS: Color.White, Android: Color.White, WinPhone: Color.Black);
            tree.Levels.Add(level);
            tree.DataSource = new PopulationViewModel().PopulationDetails;
            if (Device.Idiom == TargetIdiom.Phone && Device.OS == TargetPlatform.Windows)
            {
                tree.LegendSettings = new LegendSettings()
                {
                    Size = new Size(0, 0), ShowLegend = false
                };
            }
            else
            {
                tree.LegendSettings = new LegendSettings()
                {
                    LabelStyle = new Syncfusion.SfTreeMap.XForms.Style()
                    {
                        Font  = Device.OnPlatform(iOS: Font.SystemFontOfSize(12), Android: Font.SystemFontOfSize(14), WinPhone: Font.SystemFontOfSize(12)),
                        Color = Color.Gray
                    },
                    IconSize   = iconSize,
                    ShowLegend = true,
                    Size       = legendSize
                };
                if (Device.Idiom == TargetIdiom.Tablet)
                {
                    tree.LegendSettings.Size = new Size(500, 30);
                }
            }
            uniMapping = new UniColorMapping()
            {
                Color = Color.FromHex("#D21243")
            };

            paletteMapping = new PaletteColorMapping();
            paletteMapping.Colors.Add(Color.FromHex("#BD8EC2"));
            paletteMapping.Colors.Add(Color.FromHex("#FFD34E"));
            paletteMapping.Colors.Add(Color.FromHex("#55B949"));
            paletteMapping.Colors.Add(Color.FromHex("#00B2DA"));
            paletteMapping.Colors.Add(Color.FromHex("#744A94"));
            paletteMapping.Colors.Add(Color.FromHex("#A1A616"));
            paletteMapping.Colors.Add(Color.FromHex("#0753A1"));
            DrawOptionsPage();

            this.PropertyView = GetOptionPage();
            this.ContentView  = tree;
            this.ContentView.BackgroundColor = Color.White;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SfTreeMap treeMap = new SfTreeMap(this);

            treeMap.ColorValuePath  = "Growth";
            treeMap.WeightValuePath = "Population";
            treeMap.LayoutType      = Com.Syncfusion.Treemap.Enums.LayoutType.Squarified;
            treeMap.ShowTooltip     = true;

            LeafItemSetting leafItemSetting = new LeafItemSetting();

            leafItemSetting.ShowLabels = true;
            leafItemSetting.Gap        = 2;
            leafItemSetting.LabelPath  = "Country";
            treeMap.LeafItemSettings   = leafItemSetting;

            TreeMapFlatLevel flatLevel = new TreeMapFlatLevel();

            flatLevel.HeaderHeight     = 20;
            flatLevel.GroupPath        = "Continent";
            flatLevel.GroupGap         = 5;
            flatLevel.ShowHeader       = true;
            flatLevel.GroupStrokeColor = Color.Gray;
            flatLevel.GroupStrokeWidth = 1;
            flatLevel.HeaderStyle      = new Style()
            {
                TextColor = Color.Black
            };
            treeMap.Levels.Add(flatLevel);

            LegendSetting legendSettings = new LegendSetting();

            legendSettings.ShowLegend = true;
            legendSettings.LegendSize = new Size(700, 45);
            legendSettings.LabelStyle = new Style()
            {
                TextColor = Color.Black
            };
            treeMap.LegendSettings = legendSettings;

            RangeColorMapping rangeColorMapping = new RangeColorMapping();

            Range range1 = new Range();

            range1.From        = 0;
            range1.To          = 1;
            range1.Color       = Color.ParseColor("#77D8D8");
            range1.LegendLabel = "1 % Growth";

            Range range2 = new Range();

            range2.From        = 0;
            range2.To          = 2;
            range2.Color       = Color.ParseColor("#AED960");
            range2.LegendLabel = "2 % Growth";

            Range range3 = new Range();

            range3.From        = 0;
            range3.To          = 3;
            range3.Color       = Color.ParseColor("#FFAF51");
            range3.LegendLabel = "3 % Growth";

            Range range4 = new Range();

            range4.From        = 0;
            range4.To          = 4;
            range4.Color       = Color.ParseColor("#F3D240");
            range4.LegendLabel = "4 % Growth";

            rangeColorMapping.Ranges.Add(range1);
            rangeColorMapping.Ranges.Add(range2);
            rangeColorMapping.Ranges.Add(range3);
            rangeColorMapping.Ranges.Add(range4);

            treeMap.LeafItemColorMapping = rangeColorMapping;
            treeMap.DataSource           = GetDataSource();

            SetContentView(treeMap);
        }
		public GettingStarted ()
		{
			baritem = new ToolbarItem();
			tree = new SfTreeMap();
			Title = "GettingStarted";
			this.BackgroundColor = Device.OnPlatform(iOS: Color.White, Android: Color.White, WinPhone: Color.Black);
			tree.WeightValuePath = "Population";
			tree.ColorValuePath = "Growth";
			tree.LeafItemSettings = new LeafItemSettings();
			tree.LeafItemSettings.BorderColor =  Device.OnPlatform(iOS: Color.Gray, Android: Color.White, WinPhone:IsDarkTheme ? Color.White : Color.Gray);
			tree.LeafItemSettings.BorderWidth = Device.OnPlatform(iOS: 1, Android:2, WinPhone:2);
			tree.LeafItemSettings.Gap = Device.OnPlatform(iOS:1 , Android: 5, WinPhone: 3);
			tree.LeafItemSettings.LabelStyle = new Syncfusion.SfTreeMap.XForms.Style() { Font = Font.SystemFontOfSize(18), Color = Color.White };
			tree.LeafItemSettings.LabelPath = "Country";
			ObservableCollection<Range> ranges = new ObservableCollection<Range>();
			ranges.Add(new Range() { LegendLabel = "1 % Growth", From = 0, To = 1, Color = Color.FromHex("#77D8D8") });
			ranges.Add(new Range() { LegendLabel = "2 % Growth", From = 0, To = 2, Color = Color.FromHex("#AED960") });
			ranges.Add(new Range() { LegendLabel = "3 % Growth", From = 0, To = 3, Color = Color.FromHex("#FFAF51") });
			ranges.Add(new Range() { LegendLabel = "4 % Growth", From = 0, To = 4, Color = Color.FromHex("#F3D240") });
			tree.LeafItemColorMapping = rangeMapping = new RangeColorMapping() { Ranges = ranges };
			Size legendSize = Device.OnPlatform(iOS: new Size(300, 60), Android: new Size(200, 60), WinPhone: new Size(420, 75));
			Size iconSize = Device.OnPlatform(iOS: new Size(17, 17), Android: new Size(25, 25), WinPhone: new Size(15, 15));

			
			treeMapColorMapping = rangeMapping;
			desaturationMapping = new DesaturationColorMapping (){ From = 1, To = 0.2, Color = Color.FromHex ("#02AEDC") };
			TreeMapFlatLevel level = new TreeMapFlatLevel() { HeaderStyle = new Syncfusion.SfTreeMap.XForms.Style() { Color= Device.OnPlatform(iOS: Color.Gray, Android: Color.Gray, WinPhone: Color.White) }, GroupPath = "Continent", HeaderHeight = 20, GroupGap = 5, ShowHeader = true };
			level.GroupBackground = Device.OnPlatform(iOS: Color.White, Android: Color.White, WinPhone: Color.Black);
			tree.Levels.Add (level);
			tree.DataSource = new PopulationViewModel ().PopulationDetails;
            if (Device.Idiom == TargetIdiom.Phone && Device.OS == TargetPlatform.Windows)
            {
                tree.LegendSettings = new LegendSettings() { Size = new Size(0, 0),ShowLegend = false };
            }
            else
            {

                tree.LegendSettings = new LegendSettings()
                {
                    LabelStyle = new Syncfusion.SfTreeMap.XForms.Style()
                    {
                        Font = Device.OnPlatform(iOS: Font.SystemFontOfSize(12), Android: Font.SystemFontOfSize(14), WinPhone: Font.SystemFontOfSize(12)),
                        Color = Color.Gray
                    },
                    IconSize = iconSize,
                    ShowLegend = true,
                    Size = legendSize
                };
                if (Device.Idiom == TargetIdiom.Tablet)
                {
                    tree.LegendSettings.Size = new Size(500, 30);
                }

            }
			uniMapping = new UniColorMapping (){ Color = Color.FromHex ("#D21243") };

			paletteMapping = new PaletteColorMapping ();
			paletteMapping.Colors.Add (Color.FromHex ("#BD8EC2"));
			paletteMapping.Colors.Add (Color.FromHex ("#FFD34E"));
			paletteMapping.Colors.Add (Color.FromHex ("#55B949"));
			paletteMapping.Colors.Add (Color.FromHex ("#00B2DA"));
			paletteMapping.Colors.Add (Color.FromHex ("#744A94"));
			paletteMapping.Colors.Add (Color.FromHex ("#A1A616"));
			paletteMapping.Colors.Add (Color.FromHex ("#0753A1"));
			DrawOptionsPage ();

			this.PropertyView = GetOptionPage ();
            this.ContentView = tree;
            this.ContentView.BackgroundColor = Color.White;
		}