public PieChartPercentageCSharp()
        {
            // >> chart-piechart-percentage-csharp
            var viewModel = new ViewModel();
            var formatter = new PercentageLabelFormatter
            {
                BindingContext = viewModel
            };

            formatter.SetBinding(PercentageLabelFormatter.TotalProperty, "Total");

            var chart = new RadPieChart
            {
                BindingContext = viewModel,
                Series         =
                {
                    new PieSeries
                    {
                        ShowLabels     = true,
                        RadiusFactor   = 0.8,
                        ValueBinding   = new PropertyNameDataPointBinding("Value"),
                        LabelFormatter = formatter
                    }
                }
            };

            chart.Series[0].SetBinding(ChartSeries.ItemsSourceProperty, "Data");
            // << chart-piechart-percentage-csharp

            this.Content = chart;
        }
        public static void DispatchRunAnimations(RadChartBase chart)
        {
            IEnumerable <ChartSeries> series = null;

            RadCartesianChart cartesianChart = chart as RadCartesianChart;

            if (cartesianChart != null)
            {
                series = cartesianChart.Series;
            }

            RadPieChart pieChart = chart as RadPieChart;

            if (pieChart != null)
            {
                series = pieChart.Series;
            }

            if (series.Any(s => (int)s.GetValue(ChartAnimationUtilities.RunningAnimationsCountProperty) > 0))
            {
                return;
            }

            foreach (ChartSeries s in series)
            {
                DispatchRunSeriesAnimations(s);
            }
        }
        private void SetChartDimensions(RadPieChart chart)
        {
            if (this.RadMap1.ZoomLevel < 0)
                return;

            chart.Height = 10 * this.RadMap1.ZoomLevel;
            chart.Width = 10 * this.RadMap1.ZoomLevel;
        }
Exemplo n.º 4
0
        public PieChartCSharp()
        {
            // >> chart-piechart-csharp
            var chart = new RadPieChart
            {
                BindingContext = new ViewModel(),
                Series         =
                {
                    new PieSeries
                    {
                        ShowLabels   = true,
                        RadiusFactor = 0.8,
                        ValueBinding = new PropertyNameDataPointBinding("Value")
                    }
                }
            };

            chart.Series[0].SetBinding(ChartSeries.ItemsSourceProperty, "Data");
            // << chart-piechart-csharp

            this.Content = chart;
        }
Exemplo n.º 5
0
        private View CreateChart()
        {
            var container = new StackLayout();

            // >> chart-features-piechart-legend-definition-cs
            var chart = new RadPieChart
            {
                BindingContext = new ViewModel(),
                HeightRequest  = 300
            };
            // >> chart-features-piechart-legendtitlebinding-cs
            var series = new PieSeries
            {
                ValueBinding       = new PropertyNameDataPointBinding("Value"),
                DisplayName        = "Value",
                LegendTitleBinding = new PropertyNameDataPointBinding("Category")
            };

            // << chart-features-piechart-legendtitlebinding-cs
            series.SetBinding(ChartSeries.ItemsSourceProperty, new Binding("Data1"));
            chart.Series.Add(series);

            var legend = new RadLegend
            {
                LegendProvider      = chart,
                HeightRequest       = 200,
                LegendItemFontColor = Color.DarkGreen,
                LegendItemFontSize  = 20
            };

            // << chart-features-piechart-legend-definition-cs

            container.Children.Add(chart);
            container.Children.Add(legend);

            return(container);
        }
        private void InitializeChart(RadPieChart chart, Location location)
        {
            this.SetChartDimensions(chart);

            randoms = new double[] { rand.Next(10000, 50000), rand.Next(10000, 50000), rand.Next(10000, 50000) };
            double sum = randoms[0] + randoms[1] + randoms[2];

            PieSeries series = new PieSeries() { ShowLabels = false };
            series.ItemsSource = new double[] { randoms[0], randoms[1], randoms[2] };
            chart.Series.Add(series);
            chart.Palette = ChartPalettes.Windows8;

            chart.SetValue(MapLayer.LocationProperty, location);
            this.VisualizationLayer.Items.Add(chart);

            HeaderedItemsControl legend = new HeaderedItemsControl();

            this.InitializeMapLegend((int)((randoms[0] * 100) / sum), (int)((randoms[1] * 100) / sum), (int)((randoms[2] * 100) / sum), legend, legendLocations[i++]);
        }        
 /// <summary>
 /// Initializes a new instance of the RadPieChartAutomationPeer class.
 /// </summary>
 public RadPieChartAutomationPeer(RadPieChart owner)
     : base(owner)
 {
 }