Ejemplo n.º 1
0
        public Hierarchical()
        {
            Title = "Hierarchical";
            tree  = new SfTreeMap();
            tree.WeightValuePath = "Sales";
            this.BackgroundColor = Device.OnPlatform(iOS: Color.White, Android: Color.White, WinPhone: Color.Black);
            DesaturationColorMapping desat = new DesaturationColorMapping();

            desat.Color               = Color.FromHex("#41B8C4");
            desat.From                = 1;
            desat.To                  = 0.2;
            tree.ColorValuePath       = "Expense";
            tree.LeafItemColorMapping = desat;
            TreeMapHierarchicalLevel level = new TreeMapHierarchicalLevel()
            {
                ChildPadding = 4, HeaderStyle = new Syncfusion.SfTreeMap.XForms.Style()
                {
                    Color = Device.OnPlatform(iOS: Color.Gray, Android: Color.Gray, WinPhone: Color.White)
                }, ShowHeader = true, HeaderHeight = 20, HeaderPath = "Name", ChildPath = "RegionalSales"
            };

            level.ChildBackground = Device.OnPlatform(iOS: Color.White, Android: Color.White, WinPhone: Color.Black);
            tree.Levels.Add(level);
            tree.LeafItemSettings.LabelPath = "Name";
            tree.DataSource = new CountrySalesCollection();
            //double labelHeight = Device.OnPlatform(iOS: 20, Android: 25, WinPhone: 35);

            this.ContentView = tree;
            this.ContentView.BackgroundColor = Color.White;
        }
Ejemplo n.º 2
0
        public override View GetSampleContent(Context context)
        {
            var margin = context.Resources.DisplayMetrics.Density * 20;

            tree = new SfTreeMap(context);
            tree.WeightValuePath = "Sales";
            currentToast         = new Toast(context);

            DesaturationColorMapping desat = new DesaturationColorMapping();

            desat.Color               = Color.ParseColor("#41B8C4");
            desat.From                = 1;
            desat.To                  = 0.2;
            tree.ColorValuePath       = "Expense";
            tree.LeafItemColorMapping = desat;
            tree.HighlightOnSelection = true;
            tree.SelectionMode        = SelectionMode.Single;
            TreeMapHierarchicalLevel level = new TreeMapHierarchicalLevel()
            {
                ChildPadding = 4, ShowHeader = true, HeaderHeight = 20, HeaderPath = "Name", ChildStrokeColor = Color.Gray, ChildStrokeWidth = 1, ChildPath = "RegionalSales"
            };

            level.HeaderStyle = new Style()
            {
                TextColor = Color.Gray, TextSize = 16
            };
            level.ChildBackgroundColor = Color.White;
            tree.Levels.Add(level);
            tree.LeafItemSettings = new LeafItemSetting()
            {
                ShowLabels = true, Gap = 5, StrokeColor = Color.White, StrokeWidth = 2
            };
            tree.LeafItemSettings.LabelStyle = new Style()
            {
                Margin = new Margin(margin / 2, margin, 0, 0), TextSize = 18, TextColor = Color.White
            };
            tree.LeafItemSettings.LabelPath = "Name";
            tree.DataSource = GetDataSource();
            //tree.TreeMapSelected += (object sender, SfTreeMap.TreeMapSelectedEventArgs e) =>
            //{
            //	JSONObject data = (JSONObject)e.P0;
            //	if (data != null)
            //	{
            //		if (currentToast != null)
            //		{
            //			currentToast.Cancel();
            //		}
            //		currentToast = Toast.MakeText(context,"Country -"+ data.Get("Name") + "\n" + "Sales -$"+ data.Get("Sales"), ToastLength.Short);					currentToast.Show();
            //	}

            //};

            return(tree);
        }