protected override void InitializeControls()
        {
            _flexChart = new FlexChart()
            {
                Dock = DockStyle.Fill
            };
            _flexPie = new FlexPie()
            {
                Dock = DockStyle.Fill
            };
            //Set default chart to be shown
            this.Chart = _flexChart;

            _cbChartType = new ComboBoxEx("Chart Type")
            {
                DataSource = new string[] { "FlexChart", "FlexPie" }
            };
            _cbChartType.SelectedIndexChanged += _cbChartType_SelectedIndexChanged;

            _bSaveImage        = new ButtonEx("Save As Image");
            _bSaveImage.Click += _bSaveImage_Click;

            this.pnlControls.Controls.Add(_cbChartType);
            this.pnlControls.Controls.Add(_bSaveImage);
        }
예제 #2
0
        private void FlexPieAnimation_Load(object sender, EventArgs e)
        {
            chart = new FlexPie()
            {
                Dock = DockStyle.Fill
            };
            chart.DataLabel.Content = "{Value}";

            tableLayoutPanel1.SetRow(chart, 1);
            tableLayoutPanel1.SetColumn(chart, 1);
            tableLayoutPanel1.Controls.Add(chart);

            numInnerRadius.ValueChanged += (s, a) => chart.InnerRadius = (double)numInnerRadius.Value;
            numOffset.ValueChanged      += (s, a) => chart.Offset = (double)numOffset.Value;

            cbAnimation.DataSource            = new AnimationSettings[] { AnimationSettings.None, AnimationSettings.Load, AnimationSettings.Update, AnimationSettings.All };
            cbAnimation.SelectedValueChanged += (s, a) =>
            {
                chart.AnimationSettings = (AnimationSettings)Enum.Parse(typeof(AnimationSettings), cbAnimation.SelectedItem.ToString());
                propertyGrid1.Enabled   = (chart.AnimationSettings & AnimationSettings.Load) != 0;
                propertyGrid2.Enabled   = (chart.AnimationSettings & AnimationSettings.Update) != 0;
            };
            cbAnimation.SelectedIndex = cbAnimation.Items.Count - 1;

            propertyGrid1.SelectedObject = chart.AnimationLoad;
            propertyGrid2.SelectedObject = chart.AnimationUpdate;

            NewData();
        }
예제 #3
0
        public static StackLayout GetAnimatedSwitch(FlexPie flexPie)
        {
            Label label = new Label();

            label.Text = "Animated?";

            label.VerticalOptions   = LayoutOptions.FillAndExpand;
            label.HorizontalOptions = LayoutOptions.FillAndExpand;

            Switch toggleSwitch = new Switch();

            toggleSwitch.IsToggled = true;

            toggleSwitch.Toggled += (e, sender) =>
            {
                Switch sentSwitch = (Switch)e;

                flexPie.IsAnimated = sentSwitch.IsToggled;
            };

            StackLayout stack = new StackLayout();

            stack.Orientation = StackOrientation.Horizontal;

            stack.Children.Add(label);
            stack.Children.Add(toggleSwitch);

            return(stack);
        }
예제 #4
0
        public static StackLayout GetAnimatedSwitch(FlexPie flexPie)
        {
            Label label = new Label();

            label.Text = "Animated?";

            label.VerticalOptions = LayoutOptions.FillAndExpand;
            label.HorizontalOptions = LayoutOptions.FillAndExpand;

            Switch toggleSwitch = new Switch();

            toggleSwitch.IsToggled = true;

            toggleSwitch.Toggled += (e, sender) =>
            {
                Switch sentSwitch = (Switch) e;

                flexPie.IsAnimated = sentSwitch.IsToggled;
            };

            StackLayout stack = new StackLayout();

            stack.Orientation = StackOrientation.Horizontal;

            stack.Children.Add(label);
            stack.Children.Add(toggleSwitch);

            return stack;
        }
        public override void ViewDidLayoutSubviews()
        {
            base.ViewDidLayoutSubviews();
            FlexPie p = (FlexPie)View.ViewWithTag(1);

            p.Frame = new CoreGraphics.CGRect(0, 44, View.Bounds.Width, View.Bounds.Height - 44);
        }
        protected override void InitializeControls()
        {
            _flexChart = new FlexChart()
            {
                Dock = DockStyle.Fill
            };
            _flexPie = new FlexPie()
            {
                Dock = DockStyle.Fill
            };
            //Set the Chart to be displayed by default
            this.Chart = _flexChart;

            _cbChartType = new ComboBoxEx("Chart Type")
            {
                DataSource = new string[] { "FlexChart", "FlexPie" }
            };
            _cbChartType.SelectedIndexChanged += _cbChartType_SelectedIndexChanged;

            _bExportToFile        = new ButtonEx("Serialize To File");
            _bExportToFile.Click += _bExportToFile_Click;

            _bImportFromFile        = new ButtonEx("Deserialize From File");
            _bImportFromFile.Click += _bImportFromFile_Click;

            this.pnlControls.Controls.Add(_cbChartType);
            this.pnlControls.Controls.Add(_bExportToFile);
            this.pnlControls.Controls.Add(_bImportFromFile);
        }
예제 #7
0
        public static StackLayout getFooterEntry(FlexPie chart)
        {
            Label label = new Label();

            label.VerticalOptions   = LayoutOptions.FillAndExpand;
            label.HorizontalOptions = LayoutOptions.FillAndExpand;

            label.Text = "Footer";

            Entry entry = new Entry();

            entry.Text = footerText;

            entry.VerticalOptions   = LayoutOptions.FillAndExpand;
            entry.HorizontalOptions = LayoutOptions.FillAndExpand;

            entry.TextChanged += (e, sender) =>
            {
                Entry sentEntry = (Entry)e;

                chart.FooterText = sentEntry.Text;
            };

            StackLayout stack = new StackLayout();

            stack.Orientation = StackOrientation.Vertical;

            stack.Children.Add(label);
            stack.Children.Add(entry);

            return(stack);
        }
        /// <summary>
        /// Deserializes a FlexPie control from a file.
        /// </summary>
        /// <param name="filename">The full path of the file containing a serialized FlexPie control.</param>
        /// <param name="flexPie">The instance of the FlexPie control into which the serialized chart data is to be loaded.</param>
        /// <param name="format">A string specifying the format to use for deserialization.  Presently this includes
        /// "xml", "json", "binary" and "base64" format specifications.</param>
        /// <returns>A boolean value indicating true if the deserialization from the file was successfull.</returns>
        public static bool DeserializeFlexPieFromFile(string filename, FlexPie flexPie, string format = "xml")
        {
            bool   result = false;
            object data   = null;

            if (format == "xml" || format == "json")
            {
                data = File.ReadAllText(filename);
            }
            else if (format == "binary" || format == "base64")
            {
                data = File.ReadAllBytes(filename);
            }

            if (data != null)
            {
                try
                {
                    DeserializeFlexPieFromData(flexPie, data, format);
                    result = true;
                }
                catch { }
            }
            return(result);
        }
        public static StackLayout getFooterEntry(FlexPie chart)
        {
            Label label = new Label();

            label.VerticalOptions = LayoutOptions.FillAndExpand;
            label.HorizontalOptions = LayoutOptions.FillAndExpand;

            label.Text = "Footer";

            Entry entry = new Entry();

            entry.Text = footerText;

            entry.VerticalOptions = LayoutOptions.FillAndExpand;
            entry.HorizontalOptions = LayoutOptions.FillAndExpand;

            entry.TextChanged += (e, sender) =>
            {
                Entry sentEntry = (Entry)e;

                chart.FooterText = sentEntry.Text;
            };

            StackLayout stack = new StackLayout();

            stack.Orientation = StackOrientation.Vertical;

            stack.Children.Add(label);
            stack.Children.Add(entry);

            return stack;
        }
예제 #10
0
        void UpdateBindings(FlexPie chart)
        {
            var binds = dataMap.Bindings;
            var bndn  = binds["Name"];

            if (bndn.Count > 0)
            {
                chart.Binding = bndn[0].Name;
            }
            else
            {
                chart.Binding = null;
            }

            var bndv = binds["Value"];

            if (bndv.Count > 0)
            {
                var bind = "";
                for (var i = 0; i < bndv.Count; i++)
                {
                    if (!string.IsNullOrEmpty(bind))
                    {
                        bind += ",";
                    }
                    bind += bndv[i].Name;
                }
                chart.Binding = bind;
            }
            else
            {
                chart.Binding = null;
            }
        }
예제 #11
0
        FlexPie CreateProfitChart()
        {
            //--
            var pie = new FlexPie()
            {
                BindingName       = "Outcome",
                Binding           = "Days",
                StartAngle        = 90,
                Dock              = DockStyle.Fill,
                SelectionMode     = ChartSelectionMode.Point,
                AnimationSettings = AnimationSettings.All
            };

            pie.Header.Content     = "Days By Gain/Loss";
            pie.Legend.Position    = Position.None;
            pie.DataLabel.Position = PieLabelPosition.Center;
            pie.DataLabel.Content  = "{name} {Percent:n0}%";
            pie.ToolTip.Content    = "{value} days";
            pie.CustomPalette      = new List <Brush> {
                new SolidBrush(Color.FromArgb(192, palette2[0])),
                new SolidBrush(Color.FromArgb(192, palette2[2]))
            };

            return(pie);
        }
예제 #12
0
        public static StackLayout GetSelectedItemPositionPicker(FlexPie chart)
        {
            StackLayout stack = new StackLayout();

            stack.Orientation = StackOrientation.Horizontal;

            Label label = new Label();

            label.Text = "Selected Item Position";

            Picker picker = new Picker();

            picker.VerticalOptions = LayoutOptions.FillAndExpand;
            picker.HorizontalOptions = LayoutOptions.FillAndExpand;
            picker.Title = "Selected Item Position";

            picker.Items.Add("None");
            picker.Items.Add("Left");
            picker.Items.Add("Top");
            picker.Items.Add("Right");
            picker.Items.Add("Bottom");

            picker.SelectedIndex = 2;

            picker.SelectedIndexChanged += (e, sender) =>
            {
                Picker sentPicker = (Picker)e;

                ChartPositionType legendPoistion = ChartPositionType.Bottom;

                switch (sentPicker.SelectedIndex)
                {
                    case 0:
                        legendPoistion = ChartPositionType.None;
                        break;
                    case 1:
                        legendPoistion = ChartPositionType.Left;
                        break;
                    case 2:
                        legendPoistion = ChartPositionType.Top;
                        break;
                    case 3:
                        legendPoistion = ChartPositionType.Right;
                        break;
                    case 4:
                        legendPoistion = ChartPositionType.Bottom;
                        break;
                }

                chart.SelectedItemPosition = legendPoistion;
            };

            stack.Children.Add(label);
            stack.Children.Add(picker);

            return stack;

        }
        public static StackLayout GetOffsetStepper(FlexPie flexPie)
        {
            Label label = new Label();

            label.Text = "Offset";

            label.VerticalOptions   = LayoutOptions.FillAndExpand;
            label.HorizontalOptions = LayoutOptions.FillAndExpand;

            Label value = new Label();

            value.Text = "0.0";

            value.VerticalOptions   = LayoutOptions.FillAndExpand;
            value.HorizontalOptions = LayoutOptions.FillAndExpand;

            StackLayout labelStack = new StackLayout();

            labelStack.Orientation = StackOrientation.Vertical;

            labelStack.Children.Add(label);
            labelStack.Children.Add(value);

            Stepper stepper = new Stepper();

            stepper.VerticalOptions   = LayoutOptions.FillAndExpand;
            stepper.HorizontalOptions = LayoutOptions.FillAndExpand;

            stepper.Increment = .10;
            stepper.Minimum   = 0;
            stepper.Maximum   = 1.00;

            stepper.ValueChanged += (e, sender) =>
            {
                Stepper sentStepper = (Stepper)e;

                if (sentStepper.Value > 0)
                {
                    value.Text = sentStepper.Value.ToString();
                }
                else
                {
                    value.Text = "0.0";
                }

                flexPie.Offset = sentStepper.Value;
            };

            StackLayout stack = new StackLayout();

            stack.Orientation = StackOrientation.Horizontal;

            stack.Children.Add(labelStack);
            stack.Children.Add(stepper);

            return(stack);
        }
        private static FlexPie SalesExpensesDownloads()
        {
            FlexPie chart = new FlexPie();
            chart.BindingName = "Name";
            chart.Binding = "Value";
            chart.ItemsSource = CreateEntiyList();

            return chart;
        }
        private static void DeserializeFlexPieFromData(FlexPie flexPie, object flexPieData, string format = "xml")
        {
            flexPie.BeginUpdate();

            PieModel model = DeserializeModelFromData(typeof(PieModel), flexPieData, format) as PieModel;

            PieModel.Load(flexPie, model);

            flexPie.EndUpdate();
        }
예제 #16
0
        private static FlexPie SalesExpensesDownloads()
        {
            FlexPie chart = new FlexPie();

            chart.BindingName = "Name";
            chart.Binding     = "Value";
            chart.ItemsSource = CreateEntiyList();

            return(chart);
        }
예제 #17
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.flexpie_activity_selection);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = GetString(Resource.String.selection);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            // initializing widgets
            mFlexPie          = (FlexPie)FindViewById(Resource.Id.flexPie);
            mOffset           = (TextView)FindViewById(Resource.Id.offset);
            mButtonMinus      = (Button)FindViewById(Resource.Id.buttonMinus);
            mButtonPlus       = (Button)FindViewById(Resource.Id.buttonPlus);
            mSelectionSpinner = (Spinner)FindViewById(Resource.Id.selectionSpinner);

            // creating a list of fruit objects of type BindObject
            IList <Object> flexpieFruits = new List <Object>();

            flexpieFruits.Add(new BindObject("Oranges", 11));
            flexpieFruits.Add(new BindObject("Apples", 94));
            flexpieFruits.Add(new BindObject("Pears", 93));
            flexpieFruits.Add(new BindObject("Bananas", 2));
            flexpieFruits.Add(new BindObject("Pineapples", 53));

            // set the binding of FlexPie to variables of BindObject
            mFlexPie.BindingName = "Name";
            mFlexPie.Binding     = "Value";

            // setting the source of data/items and default values in FlexPie
            mFlexPie.ItemsSource        = flexpieFruits;
            mOffset.Text                = mOffsetValue.ToString();
            mFlexPie.SelectedItemOffset = mOffsetValue;
            mFlexPie.SelectionMode      = ChartSelectionModeType.Point;

            // initializing adapter to string array
            ArrayAdapter adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.selection_spinner_values, Android.Resource.Layout.SimpleSpinnerItem);

            // Specify the layout to use when the list of choices appears
            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            // Apply the adapter to the spinner
            mSelectionSpinner.Adapter       = adapter;
            mSelectionSpinner.ItemSelected += mSelectionSpinner_ItemSelected;

            mSelectionSpinner.SetSelection(1);

            Button button = (Button)FindViewById(Resource.Id.buttonMinus);

            button.Click += button_Click;
            button        = (Button)FindViewById(Resource.Id.buttonPlus);
            button.Click += button_Click;
        }
        public LegendAndTitlesSample(PieChartSample chartSample)
            : base()
        {
            FlexPie chart = PieChartSampleFactory.GetFlexChartSample(chartSample);

            chart.HeaderText      = EntryInputs.headerText;
            chart.HeaderFont      = Font.SystemFontOfSize(30);
            chart.HeaderTextColor = Color.FromHex("#666666");

            chart.FooterText      = EntryInputs.footerText;
            chart.FooterFont      = Font.SystemFontOfSize(15);
            chart.FooterTextColor = Color.FromHex("#666666");

            chart.Legend.Position = Xuni.Xamarin.ChartCore.ChartPositionType.Bottom;

            RelativeLayout mainRelativeLayout = new RelativeLayout();

            WrapLayout stepperStack = new WrapLayout();

            stepperStack.Orientation = StackOrientation.Horizontal;

            Entry headerEntry = new Entry();

            headerEntry.VerticalOptions   = LayoutOptions.FillAndExpand;
            headerEntry.HorizontalOptions = LayoutOptions.FillAndExpand;

            stepperStack.Children.Add(EntryInputs.getHeaderEntry(chart));
            stepperStack.Children.Add(EntryInputs.getFooterEntry(chart));
            stepperStack.Children.Add(Pickers.GetLegendPositionPicker(chart));

            mainRelativeLayout.Children.Add(stepperStack, Constraint.Constant(0),
                                            Constraint.Constant(0));

            mainRelativeLayout.Children.Add(chart, Constraint.Constant(0), Constraint.RelativeToView(stepperStack, (parent, sibling) =>
            {
                return(sibling.Y + sibling.Height);
            }),
                                            Constraint.RelativeToView(stepperStack, (parent, sibling) =>
            {
                return(parent.Width);
            }),
                                            Constraint.RelativeToView(stepperStack, (parent, sibling) =>
            {
                return(parent.Height - sibling.Height);
            }));
            // On Windows Phone,StackLayout and Picker will shrink automatically.
            // http://forums.xamarin.com/discussion/22436/picker-is-shrink-on-windows-phone-8
            mainRelativeLayout.SizeChanged += (s, e) =>
            {
                stepperStack.WidthRequest = mainRelativeLayout.Width;
            };

            Content = mainRelativeLayout;
        }
 protected override void SetupChart()
 {
     fpie = new FlexPie()
     {
         Dock = DockStyle.Fill
     };
     fpie.Legend.Position   = Position.Right;
     fpie.DataLabel.Content = "{Value}";
     Chart = fpie;
     NewData();
 }
예제 #20
0
 public MyTooltip(FlexPie pie, Context context)
     : base(pie)
 {
     txtLabel = new TextView(context);
     LinearLayout layout = new LinearLayout(context);
     layout.Orientation = Orientation.Vertical;
     layout.SetBackgroundColor(Android.Graphics.Color.Gray);
     layout.SetPadding(5, 5, 5, 5);
     layout.AddView(txtLabel);
     AddView(layout);
 }
예제 #21
0
 void Attach(FlexPie fp)
 {
     fp.SliceRendered += (s, a) =>
     {
         center = new _Point(a.CenterX, a.CenterY);
         radius = a.Radius;
     };
     fp.Rendered  += PieOnRendered;
     fp.MouseMove += PieOnMouseMove;
     fp.Click     += OnClick;
 }
예제 #22
0
        private void PieOnMouseMove(object sender, MouseEventArgs e)
        {
            var ht  = FlexPie.HitTest(e.Location);
            var par = new _Rect(center.X - radius, center.Y - radius, 2 * radius, 2 * radius);
            var el  = ht.ChartElement;

            if (par.Contains(e.X, e.Y))
            {
                el = ChartElement.PlotArea;
            }
            HoverElement = el;
        }
        protected override void InitializeControls()
        {
            flexChart1 = new FlexChart();
            this.Chart = flexChart1;

            _flexPie = new FlexPie()
            {
                Dock = DockStyle.Fill, BackColor = Color.White
            };

            _cbGroupBy = new ComboBoxEx("Group By")
            {
                Width = 160, DataSource = _groups
            };
            _cbGroupBy.SelectedIndexChanged += _cbGroupBy_SelectedIndexChanged;

            _cbAggregateType       = ControlFactory.EnumBasedCombo(typeof(AggregateType), "Aggregate Type");
            _cbAggregateType.Width = 160;
            _cbAggregateType.SelectedIndexChanged += (s, e) =>
            {
                manager.AggregateType = (AggregateType)Enum.Parse(typeof(AggregateType), _cbAggregateType.SelectedValue.ToString());
                UpdateChart();
            };

            _cbChartType = new ComboBoxEx("Chart Type")
            {
                DataSource = _chartTypes
            };
            _cbChartType.SelectedIndexChanged += _cbChartType_SelectedIndexChanged;

            _chbEnableDrill = new CheckBoxEx("Enable DrillDown")
            {
                Checked = isDrillDownEnabled
            };
            _chbEnableDrill.CheckedChanged += (s, e) => { isDrillDownEnabled = _chbEnableDrill.Checked; };

            _pNavBar = new FlowLayoutPanel()
            {
                FlowDirection = FlowDirection.LeftToRight,
                AutoSize      = true,
                WrapContents  = false,
                Font          = new Font(this.Font.FontFamily, 11),
                Padding       = new Padding(5),
            };

            this.pnlControls.AutoSize = true;
            this.pnlControls.Controls.Add(_cbGroupBy);
            this.pnlControls.Controls.Add(_cbAggregateType);
            this.pnlControls.Controls.Add(_cbChartType);
            this.pnlControls.Controls.Add(_chbEnableDrill);
            this.pnlControls.Controls.Add(_pNavBar);
            this.pnlControls.SetFlowBreak(_chbEnableDrill, true);
        }
        public MyTooltip(FlexPie pie, Context context)
            : base(pie)
        {
            txtLabel = new TextView(context);
            LinearLayout layout = new LinearLayout(context);

            layout.Orientation = Orientation.Vertical;
            layout.SetBackgroundColor(Android.Graphics.Color.Gray);
            layout.SetPadding(5, 5, 5, 5);
            layout.AddView(txtLabel);
            AddView(layout);
        }
        protected override void InitializeControls()
        {
            fpie = new FlexPie()
            {
                Dock = DockStyle.Fill
            };
            Chart = fpie;

            pnlControls.Controls.Add(new LabelEx("Inner Radius"));
            var numInnerRadius = new NumericUpDownEx()
            {
                Minimum = 0, Maximum = 0.9M, Increment = 0.1M, DecimalPlaces = 1, Value = 0
            };

            numInnerRadius.ValueChanged += (s, a) => fpie.InnerRadius = (double)numInnerRadius.Value;
            pnlControls.Controls.Add(numInnerRadius);

            pnlControls.Controls.Add(new LabelEx("Offset"));
            var numOffset = new NumericUpDownEx()
            {
                Minimum = 0, Maximum = 1, Increment = 0.1M, DecimalPlaces = 1, Value = 0
            };

            numOffset.ValueChanged += (s, a) => fpie.Offset = (double)numOffset.Value;
            pnlControls.Controls.Add(numOffset);

            var cbLabels = new CheckBoxEx("Show Labels");

            cbLabels.CheckedChanged += (s, a) => fpie.DataLabel.Position = cbLabels.Checked ? PieLabelPosition.Center : PieLabelPosition.None;
            pnlControls.SetFlowBreak(cbLabels, true);
            pnlControls.Controls.Add(cbLabels);

            var btnNew = new ButtonEx("New Data");

            btnNew.Click += (s, a) => NewData();
            pnlControls.Controls.Add(btnNew);

            var btnUpdate = new ButtonEx("Update");

            btnUpdate.Click += (s, a) => UpdateData();
            pnlControls.Controls.Add(btnUpdate);

            var btnAddPoint = new ButtonEx("+ Point");

            btnAddPoint.Click += (s, a) => AddPoint();
            pnlControls.Controls.Add(btnAddPoint);

            var btnRemovePoint = new ButtonEx("- Point");

            btnRemovePoint.Click += (s, a) => RemovePoint();
            pnlControls.Controls.Add(btnRemovePoint);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.flexpie_activity_basic_features);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = GetString(Resource.String.basic_features);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            // initializing widgets
            mflexPie           = (FlexPie)FindViewById(Resource.Id.donutPie);
            mRadius            = (TextView)FindViewById(Resource.Id.radius);
            mReversedSwitch    = (Switch)FindViewById(Resource.Id.reversedSwitch);
            mOffsetSeekbar     = (SeekBar)FindViewById(Resource.Id.offsetSeekBar);
            mStartAngleSeekbar = (SeekBar)FindViewById(Resource.Id.startAngleSeekBar);
            mButtonMinus       = (Button)FindViewById(Resource.Id.buttonMinus);
            mButtonPlus        = (Button)FindViewById(Resource.Id.buttonPlus);

            // creating a list of fruit objects of type BindObject
            IList <Object> mFlexdonutFruits = new List <Object>();

            mFlexdonutFruits.Add(new BindObject("Oranges", 11));
            mFlexdonutFruits.Add(new BindObject("Apples", 94));
            mFlexdonutFruits.Add(new BindObject("Pears", 93));
            mFlexdonutFruits.Add(new BindObject("Bananas", 2));
            mFlexdonutFruits.Add(new BindObject("Pineapples", 53));

            // set the binding of FlexPie to variables of BindObject
            mflexPie.BindingName = "Name";
            mflexPie.Binding     = "Value";

            // setting the source of data/items in FlexPie
            mflexPie.ItemsSource = mFlexdonutFruits;

            // setting default values
            mRadius.Text         = mInnerRadius.ToString();
            mflexPie.InnerRadius = mInnerRadius;

            mReversedSwitch.CheckedChange += mReversedSwitch_CheckedChange;

            mOffsetSeekbar.ProgressChanged     += mOffsetSeekbar_ProgressChanged;
            mStartAngleSeekbar.ProgressChanged += mStartAngleSeekbar_ProgressChanged;

            Button button = (Button)FindViewById(Resource.Id.buttonMinus);

            button.Click += button_Click;
            button        = (Button)FindViewById(Resource.Id.buttonPlus);
            button.Click += button_Click;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.flexpie_activity_data_labels);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = GetString(Resource.String.dataLabels);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            // initializing widgets
            mFlexPie          = (FlexPie)FindViewById(Resource.Id.flexPie);
            mDataLabelSpinner = (Spinner)FindViewById(Resource.Id.dataLabelSpinner);

            // creating a list of fruit objects of type BindObject
            mFlexdonutFruits = new List <Object>();
            mFlexdonutFruits.Add(new BindObject("Oranges", 11));
            mFlexdonutFruits.Add(new BindObject("Apples", 94));
            mFlexdonutFruits.Add(new BindObject("Pears", 93));
            mFlexdonutFruits.Add(new BindObject("Bananas", 2));
            mFlexdonutFruits.Add(new BindObject("Pineapples", 53));

            // set the binding of FlexPie to variables of BindObject
            mFlexPie.BindingName = "Name";
            mFlexPie.Binding     = "Value";

            // setting the source of data/items in FlexPie
            mFlexPie.ItemsSource = mFlexdonutFruits;

            mFlexPie.DataLabel.Content     = "{y}";
            mFlexPie.DataLabel.Border      = true;
            mFlexPie.DataLabel.BorderStyle = new ChartStyle()
            {
                Stroke = Color.Green, StrokeThickness = 2, Fill = Color.Transparent
            };

            //MarginF mPlotMargin = new MarginF(30f, 30f, 30f, 30f);
            //mFlexPie.PlotMargin = mPlotMargin;

            // create custom adapter for spinner and initialize with string array
            ArrayAdapter adapter1 = ArrayAdapter.CreateFromResource(this, Resource.Array.pieDataLabelPositionSpinnerValues, Android.Resource.Layout.SimpleSpinnerItem);

            // Specify the layout to use when the list of choices appears
            adapter1.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            // Apply the adapter to the spinner
            mDataLabelSpinner.Adapter = adapter1;

            mDataLabelSpinner.ItemSelected += mDataLabelSpinner_ItemSelected;
        }
        public static Picker GetLegendPositionPicker(FlexPie chart)
        {
            Picker picker = new Picker();

            picker.VerticalOptions   = LayoutOptions.FillAndExpand;
            picker.HorizontalOptions = LayoutOptions.FillAndExpand;
            picker.Title             = "Legend Position";


            picker.Items.Add("None");
            picker.Items.Add("Left");
            picker.Items.Add("Top");
            picker.Items.Add("Right");
            picker.Items.Add("Bottom");

            picker.SelectedIndex = 4;

            picker.SelectedIndexChanged += (e, sender) =>
            {
                Picker sentPicker = (Picker)e;

                ChartPositionType legendPoistion = ChartPositionType.Bottom;

                switch (sentPicker.SelectedIndex)
                {
                case 0:
                    legendPoistion = ChartPositionType.None;
                    break;

                case 1:
                    legendPoistion = ChartPositionType.Left;
                    break;

                case 2:
                    legendPoistion = ChartPositionType.Top;
                    break;

                case 3:
                    legendPoistion = ChartPositionType.Right;
                    break;

                case 4:
                    legendPoistion = ChartPositionType.Bottom;
                    break;
                }

                chart.Legend.Position = legendPoistion;
            };

            return(picker);
        }
        public static StackLayout GetInnerRadiusStepper(FlexPie flexPie)
        {
            Label label = new Label();

            label.Text = "Inner Radius";

            label.VerticalOptions   = LayoutOptions.FillAndExpand;
            label.HorizontalOptions = LayoutOptions.FillAndExpand;

            Label value = new Label();

            value.Text = "0.3";

            value.VerticalOptions   = LayoutOptions.FillAndExpand;
            value.HorizontalOptions = LayoutOptions.FillAndExpand;

            StackLayout labelStack = new StackLayout();

            labelStack.Orientation = StackOrientation.Vertical;

            labelStack.Children.Add(label);
            labelStack.Children.Add(value);

            Stepper stepper = new Stepper();

            stepper.VerticalOptions   = LayoutOptions.FillAndExpand;
            stepper.HorizontalOptions = LayoutOptions.FillAndExpand;

            stepper.Value     = 0.3;
            stepper.Increment = .10;
            stepper.Minimum   = 0;
            stepper.Maximum   = 1.00;

            stepper.ValueChanged += (e, sender) =>
            {
                Stepper sentStepper = (Stepper)e;

                value.Text = String.Format("{0:F1}", sentStepper.Value);

                flexPie.InnerRadius = sentStepper.Value;
            };

            StackLayout stack = new StackLayout();

            stack.Orientation = StackOrientation.Horizontal;

            stack.Children.Add(labelStack);
            stack.Children.Add(stepper);

            return(stack);
        }
예제 #30
0
        public static StackLayout GetInnerRadiusStepper(FlexPie flexPie)
        {
            Label label = new Label();

            label.Text = "Inner Radius";

            label.VerticalOptions = LayoutOptions.FillAndExpand;
            label.HorizontalOptions = LayoutOptions.FillAndExpand;

            Label value = new Label();

            value.Text = "0.3";

            value.VerticalOptions = LayoutOptions.FillAndExpand;
            value.HorizontalOptions = LayoutOptions.FillAndExpand;

            StackLayout labelStack = new StackLayout();

            labelStack.Orientation = StackOrientation.Vertical;

            labelStack.Children.Add(label);
            labelStack.Children.Add(value);

            Stepper stepper = new Stepper();

            stepper.VerticalOptions = LayoutOptions.FillAndExpand;
            stepper.HorizontalOptions = LayoutOptions.FillAndExpand;

            stepper.Value = 0.3;
            stepper.Increment = .10;
            stepper.Minimum = 0;
            stepper.Maximum = 1.00;

            stepper.ValueChanged += (e, sender) =>
            {
                Stepper sentStepper = (Stepper)e;

                value.Text = String.Format("{0:F1}", sentStepper.Value);

                flexPie.InnerRadius =sentStepper.Value;
            };

            StackLayout stack = new StackLayout();

            stack.Orientation = StackOrientation.Horizontal;

            stack.Children.Add(labelStack);
            stack.Children.Add(stepper);

            return stack;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.flexpie_activity_getting_started);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = GetString(Resource.String.getting_started);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            // initializing widgets
            mFlexPie1 = (FlexPie)FindViewById(Resource.Id.flexPie);
            mFlexPie2 = (FlexPie)FindViewById(Resource.Id.donutPie);

            // creating a list of fruit objects of type BindObject for first FlexPie
            IList <object> flexpieFruits = new List <object>();

            flexpieFruits.Add(new BindObject("Oranges", 11));
            flexpieFruits.Add(new BindObject("Apples", 94));
            flexpieFruits.Add(new BindObject("Pears", 93));
            flexpieFruits.Add(new BindObject("Bananas", 2));
            flexpieFruits.Add(new BindObject("Pineapples", 53));

            // set the binding of FlexPie to variables of BindObject
            mFlexPie1.BindingName = "Name";
            mFlexPie1.Binding     = "Value";

            // setting the source of data/items and default values in FlexPie
            mFlexPie1.ItemsSource = flexpieFruits;

            // creating a list of fruit objects of type BindObject for second FlexPie
            IList <object> flexdonutFruits = new List <object>();

            flexdonutFruits.Add(new BindObject("Oranges", 11));
            flexdonutFruits.Add(new BindObject("Apples", 94));
            flexdonutFruits.Add(new BindObject("Pears", 93));
            flexdonutFruits.Add(new BindObject("Bananas", 2));
            flexdonutFruits.Add(new BindObject("Pineapples", 53));

            // set the binding of FlexPie to variables of BindObject
            mFlexPie2.BindingName = "Name";
            mFlexPie2.Binding     = "Value";

            // setting the source of data/items and defaulty values in FlexPie
            mFlexPie2.ItemsSource = flexdonutFruits;
            mFlexPie2.InnerRadius = 0.6f;
        }
        public SelectionSample(PieChartSample chartSample)
            : base()
        {
            FlexPie chart = PieChartSampleFactory.GetFlexChartSample(chartSample);

            chart.SelectionMode       = Xuni.Xamarin.ChartCore.ChartSelectionModeType.Point;
            chart.SelectedItemOffset  = .2;
            chart.SelectedDashes      = new double[] { 20, 10 };
            chart.SelectedBorderColor = Color.FromRgb(255, 0, 0);
            chart.SelectedBorderWidth = 3;


            chart.SelectedItemPosition = Xuni.Xamarin.ChartCore.ChartPositionType.Top;
            chart.IsAnimated           = true;

            RelativeLayout mainRelativeLayout = new RelativeLayout();

            WrapLayout stepperStack = new WrapLayout();

            stepperStack.Orientation = StackOrientation.Horizontal;

            stepperStack.Children.Add(Steppers.GetSelectedOffsetStepper(chart));
            stepperStack.Children.Add(Pickers.GetSelectedItemPositionPicker(chart));
            stepperStack.Children.Add(Switches.GetAnimatedSwitch(chart));

            mainRelativeLayout.Children.Add(stepperStack, Constraint.Constant(0),
                                            Constraint.Constant(0));

            mainRelativeLayout.Children.Add(chart, Constraint.Constant(0), Constraint.RelativeToView(stepperStack, (parent, sibling) =>
            {
                return(sibling.Y + sibling.Height);
            }),
                                            Constraint.RelativeToView(stepperStack, (parent, sibling) =>
            {
                return(parent.Width);
            }),
                                            Constraint.RelativeToView(stepperStack, (parent, sibling) =>
            {
                return(parent.Height - sibling.Height);
            }));
            // On Windows Phone,StackLayout and Picker will shrink automatically.
            // http://forums.xamarin.com/discussion/22436/picker-is-shrink-on-windows-phone-8
            mainRelativeLayout.SizeChanged += (s, e) =>
            {
                stepperStack.WidthRequest = mainRelativeLayout.Width;
            };

            Content = mainRelativeLayout;
        }
예제 #33
0
        public static Picker GetLegendPositionPicker(FlexPie chart)
        {
            Picker picker = new Picker();

            picker.VerticalOptions = LayoutOptions.FillAndExpand;
            picker.HorizontalOptions = LayoutOptions.FillAndExpand;
            picker.Title = "Legend Position";

            
            picker.Items.Add("None");
            picker.Items.Add("Left");
            picker.Items.Add("Top");
            picker.Items.Add("Right");
            picker.Items.Add("Bottom");

            picker.SelectedIndex = 4;

            picker.SelectedIndexChanged += (e, sender) =>
            {
                Picker sentPicker = (Picker)e;

                ChartPositionType legendPoistion = ChartPositionType.Bottom;

                switch (sentPicker.SelectedIndex)
                {
                    case 0:
                        legendPoistion = ChartPositionType.None;
                        break;
                    case 1:
                        legendPoistion = ChartPositionType.Left;
                        break;
                    case 2:
                        legendPoistion = ChartPositionType.Top;
                        break;
                    case 3:
                        legendPoistion = ChartPositionType.Right;
                        break;
                    case 4:
                        legendPoistion = ChartPositionType.Bottom;
                        break;
                }

                chart.Legend.Position = legendPoistion;
            };

            return picker;

        }
        /// <summary>
        /// PieModel.Load is used to set the properties of an existing FlexPie object in a FlexPie based control.
        /// The values used are those stored in an existing PieModel class object that is typically created and set by
        /// a standard serializer during deserialization.
        /// </summary>
        /// <param name="chart">Specifies an existing instance of a FlexPie class object.</param>
        /// <param name="model">Specifies an existing instannce of a PieModel class object created by a
        ///                  a standard serializer during deserialization.</param>
        public static void Load(FlexPie chart, PieModel model)
        {
            // simple properties
#if WINFORMS
            chart.Header.Content = model.Header;
            chart.Footer.Content = model.Footer;
#endif

#if WPF
            chart.Header = model.Header;
            chart.Footer = model.Footer;
#endif

            // styles
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.Style), null);
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.HeaderStyle), "Header");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.FooterStyle), "Footer");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.HeaderBorderStyle), "HeaderBorder");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.FooterBorderStyle), "FooterBorder");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.PlotStyle), "Plot");
            ((IStyleProvider)chart).SetStyle(StyleSerializer.StyleFromString(model.SelectedStyle), "Selected");
            chart.InnerRadius = model.InnerRadius;
            chart.Offset      = model.Offset;
            chart.StartAngle  = model.StartAngle;
            chart.Reversed    = model.Reversed;

            double[] values = model.Values;
            string[] names  = model.Names;

            List <FlexPieSlice> slices = new List <FlexPieSlice>();
            for (int ps = 0; ps < values.Length; ps++)
            {
                FlexPieSlice slice = new FlexPieSlice(values[ps], names[ps]);
                slices.Add(slice);
            }
            chart.Binding     = "Value";
            chart.BindingName = "Name";

#if WINFORMS
            chart.DataSource = slices;
#endif
#if WPF
            chart.ItemsSource = slices;
#endif

            LegendModel.Load(chart, model.Legend);
            PieDataLabelModel.Load(chart.DataLabel, model.DataLabel);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.flexpie_activity_legend_and_titles);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = GetString(Resource.String.legend_and_titles);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            // initializing widgets
            mFlexPie       = (FlexPie)FindViewById(Resource.Id.flexPie);
            mHeaderValue   = (EditText)FindViewById(Resource.Id.headerValue);
            mFooterValue   = (EditText)FindViewById(Resource.Id.footerValue);
            mLegendSpinner = (Spinner)FindViewById(Resource.Id.legendSpinner);

            // creating a list of fruit objects of type BindObject
            IList <Object> flexpieFruits = new List <Object>();

            flexpieFruits.Add(new BindObject("Oranges", 11));
            flexpieFruits.Add(new BindObject("Apples", 94));
            flexpieFruits.Add(new BindObject("Pears", 93));
            flexpieFruits.Add(new BindObject("Bananas", 2));
            flexpieFruits.Add(new BindObject("Pineapples", 53));

            // set the binding of FlexPie to variables of BindObject
            mFlexPie.BindingName    = "Name";
            mFlexPie.Binding        = "Value";
            mFlexPie.LegendPosition = ChartPositionType.Auto;

            // setting the source of data/items and default values in FlexPie
            mFlexPie.ItemsSource = flexpieFruits;
            mFlexPie.Header      = mHeaderValue.Text;
            mFlexPie.Footer      = mFooterValue.Text;

            // initializing adapter to string array
            ArrayAdapter adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.legend_spinner_values, Android.Resource.Layout.SimpleSpinnerItem);

            // Specify the layout to use when the list of choices appears
            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            // Apply the adapter to the spinner
            mLegendSpinner.Adapter       = adapter;
            mLegendSpinner.ItemSelected += mLegendSpinner_ItemSelected;
            mHeaderValue.TextChanged    += mHeaderValue_TextChanged;
            mFooterValue.TextChanged    += mFooterValue_TextChanged;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            pickerView.Model = new ThemeModel(this);
            pickerView.ShowSelectionIndicator = true;
            //pickerView.Hidden = false;

            pieChart                = new FlexPie();
            pieChart.Binding        = "Value";
            pieChart.BindingName    = "Name";
            pieChart.ItemsSource    = PieChartData.DemoData();
            pieChart.LegendPosition = ChartPositionType.Bottom;
            this.Add(pieChart);
        }
예제 #37
0
        void addChart()
        {
            List <Sample> list = new List <Sample>();

            for (int i = 0; i < 5; i++)
            {
                Sample sample = new Sample("Sample " + i, i + 1);
                list.Add(sample);
            }

            FlexPie pie1 = new FlexPie
            {
                ItemsSource       = list,
                HeightRequest     = 300,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BindingName       = "Name",
                Binding           = "Value"
            };


            FlexPie pie2 = new FlexPie
            {
                ItemsSource       = list,
                HeightRequest     = 300,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BindingName       = "Name",
                Binding           = "Value",
            };

            FlexChart chart1 = new FlexChart
            {
                ItemsSource   = list,
                HeightRequest = 300,
                BindingX      = "Name",
            };
            ChartSeries chartSeries = new ChartSeries
            {
                Binding    = "Value",
                SeriesName = "Nilai"
            };

            chart1.Series.Add(chartSeries);
            root.Children.Add(pie1);
            root.Children.Add(chart1);
            root.Children.Add(pie2);
        }
        public GettingStartedSample(PieChartSample chartSample)
            : base()
        {
            pieChart = PieChartSampleFactory.GetFlexChartSample(chartSample);
            donutChart = PieChartSampleFactory.GetFlexChartSample(chartSample);

            donutChart.InnerRadius = .6;

            mainRelativeLayout = new RelativeLayout();

            mainRelativeLayout.Children.Add(pieChart, Constraint.Constant(0), Constraint.Constant(0),
                Constraint.RelativeToParent((parent) =>
                {
                    return parent.Width;
                }),
                Constraint.RelativeToParent((parent) =>
                {
                    return parent.Height / 2;
                }));

            mainRelativeLayout.Children.Add(donutChart,
            Constraint.Constant(0),
            Constraint.RelativeToView(pieChart, (parent, sibling) =>
            {
                return sibling.Y + sibling.Height;
            }),
            Constraint.RelativeToParent((parent) =>
            {
                return parent.Width;
            }),
            Constraint.RelativeToParent((parent) =>
            {
                return parent.Height / 2;
            }));

            Content = mainRelativeLayout;
        }
예제 #39
0
        public static StackLayout GetOffsetStepper(FlexPie flexPie)
        {
            Label label = new Label();

            label.Text = "Offset";

            label.VerticalOptions = LayoutOptions.FillAndExpand;
            label.HorizontalOptions = LayoutOptions.FillAndExpand;

            Label value = new Label();

            value.Text = "0.0";

            value.VerticalOptions = LayoutOptions.FillAndExpand;
            value.HorizontalOptions = LayoutOptions.FillAndExpand;

            StackLayout labelStack = new StackLayout();

            labelStack.Orientation = StackOrientation.Vertical;

            labelStack.Children.Add(label);
            labelStack.Children.Add(value);

            Stepper stepper = new Stepper();

            stepper.VerticalOptions = LayoutOptions.FillAndExpand;
            stepper.HorizontalOptions = LayoutOptions.FillAndExpand;

            stepper.Increment = .10;
            stepper.Minimum = 0;
            stepper.Maximum = 1.00;

            stepper.ValueChanged += (e, sender) =>
            {
                Stepper sentStepper = (Stepper)e;

                if (sentStepper.Value > 0)
                {
                    value.Text = sentStepper.Value.ToString();
                }
                else
                {
                    value.Text = "0.0";
                }

                flexPie.Offset = sentStepper.Value;
            };

            StackLayout stack = new StackLayout();

            stack.Orientation = StackOrientation.Horizontal;

            stack.Children.Add(labelStack);
            stack.Children.Add(stepper);

            return stack;
        }
예제 #40
0
        public static Picker GetPalettePicker(FlexPie chart)
        {
            Picker picker = new Picker();

            picker.VerticalOptions = LayoutOptions.FillAndExpand;
            picker.HorizontalOptions = LayoutOptions.FillAndExpand;
            picker.Title = "Palette";

            picker.Items.Add("standard");
            picker.Items.Add("cocoa");
            picker.Items.Add("coral");
            picker.Items.Add("dark");
            picker.Items.Add("highconstrast");
            picker.Items.Add("light");
            picker.Items.Add("midnight");
            picker.Items.Add("minimal");
            picker.Items.Add("modern");
            picker.Items.Add("organic");
            picker.Items.Add("slate");

            picker.SelectedIndexChanged += (e, sender) =>
            {
                Picker sentPicker = (Picker)e;

                Color[] palette = null;

                switch (sentPicker.SelectedIndex)
                {
                    case 0:
                        palette = Palettes.Standard;
                        break;
                    case 1:
                        palette = Palettes.Cocoa;
                        break;
                    case 2:
                        palette = Palettes.Coral;
                        break;
                    case 3:
                        palette = Palettes.Dark;
                        break;
                    case 4:
                        palette = Palettes.HighContrast;
                        break;
                    case 5:
                        palette = Palettes.Light;
                        break;
                    case 6:
                        palette = Palettes.Midnight;
                        break;
                    case 7:
                        palette = Palettes.Minimal;
                        break;
                    case 8:
                        palette = Palettes.Modern;
                        break;
                    case 9:
                        palette = Palettes.Organic;
                        break;
                    case 10:
                        palette = Palettes.Slate;
                        break;
                }

                if(palette != null)
                {
                    chart.Palette = palette;
                }
            };

            return picker;

        }