public void inicializarChart2() { chart2 = new SfChart(); ViewModel vm = new ViewModel(); DoughnutSeries doughnutSeries = new DoughnutSeries() { ItemsSource = vm.Data, XBindingPath = "Direccione", YBindingPath = "Infracciones", StartAngle = 0, EndAngle = 360 }; doughnutSeries.Label = "Infracciones"; doughnutSeries.EnableTooltip = true; doughnutSeries.EnableDataPointSelection = true; doughnutSeries.EnableAnimation = true; doughnutSeries.AnimationDuration = 0.9; doughnutSeries.EnableSmartLabels = true; doughnutSeries.DataMarker = new ChartDataMarker(); chart2.Title.Text = "Infracciones por Dispositivo"; chart2.Legend = new ChartLegend(); chart2.Series.Add(doughnutSeries); chart2.Margin = new Thickness(5, 6, 5, 5); chart2.Legend.ToggleSeriesVisibility = true; chart2.VerticalOptions = LayoutOptions.FillAndExpand; chart2.MinimumHeightRequest = 350; chart2.HeightRequest = 350; }
public override View GetSampleContent(Context context) { var chart = new SfChart(context);; chart.SetBackgroundColor(Color.White); chart.Legend.Visibility = Visibility.Visible; var datas = new ObservableArrayList(); datas.Add(new ChartDataPoint("2010", 8000)); datas.Add(new ChartDataPoint("2011", 8100)); datas.Add(new ChartDataPoint("2012", 8250)); datas.Add(new ChartDataPoint("2013", 8600)); datas.Add(new ChartDataPoint("2014", 8700)); var doughnutSeries = new DoughnutSeries { ExplodeIndex = 3, DataSource = datas, DataMarkerPosition = CircularSeriesDataMarkerPosition.OutsideExtended, }; doughnutSeries.DataMarker.ShowLabel = true; doughnutSeries.ConnectorType = ConnectorType.Bezier; chart.Series.Add(doughnutSeries); return(chart); }
private void ShowRatingGraph() { List <Model> data = new List <Model> { new Model() { Rating = "Loved", Score = Context.Rates.Percentage }, new Model() { Rating = "Hated", Score = 100 - Context.Rates.Percentage } }; DoughnutSeries doughnutSeries = new DoughnutSeries() { ItemsSource = data, XBindingPath = "Rating", YBindingPath = "Score", ColorModel = new ChartColorModel() { Palette = ChartColorPalette.Custom, CustomBrushes = new ChartColorCollection() { Color.FromHex("#0F9D58"), Color.FromHex("#D23F31") } }, DoughnutCoefficient = 0.75, EnableAnimation = true, AnimationDuration = 0.75, }; chRating.Series.Add(doughnutSeries); }
public override View GetSampleContent(Context context) { var chart = new SfChart(context);; chart.Title.Text = "Project Cost Breakdown"; chart.Title.TextSize = 15; chart.SetBackgroundColor(Color.White); chart.Legend.Visibility = Visibility.Visible; chart.Legend.DockPosition = ChartDock.Bottom; chart.Legend.ToggleSeriesVisibility = true; chart.Legend.OverflowMode = ChartLegendOverflowMode.Wrap; chart.Legend.IconHeight = 14; chart.Legend.IconWidth = 14; DoughnutSeries doughnutSeries = new DoughnutSeries(); doughnutSeries.ColorModel.ColorPalette = ChartColorPalette.Natural; doughnutSeries.ExplodableOnTouch = true; doughnutSeries.DataMarker.LabelContent = LabelContent.Percentage; doughnutSeries.ItemsSource = MainPage.GetDoughnutData(); doughnutSeries.XBindingPath = "XValue"; doughnutSeries.YBindingPath = "YValue"; doughnutSeries.DataMarker.ShowLabel = true; doughnutSeries.EnableAnimation = true; chart.Series.Add(doughnutSeries); return(chart); }
/// <summary> /// ctor(). /// </summary> public BuyerPage() { InitializeComponent(); SlideMenu = new SideMenuView(); BindingContext = _viewModel = new BuyerPageViewModel(); _viewModel.Spot = spot_ContentView; SfChart chart = new SfChart(); DoughnutSeries doughnutSeries = new DoughnutSeries() { ItemsSource = _viewModel.ChartData, XBindingPath = "Name", YBindingPath = "Value", DoughnutCoefficient = 0.7, ExplodeIndex = 0 }; List <Color> colors = new List <Color>() { Color.FromHex("#82DA69"), Color.FromHex("#E47132"), Color.FromHex("#9EE5FC"), }; doughnutSeries.ColorModel.Palette = ChartColorPalette.Custom; doughnutSeries.ColorModel.CustomBrushes = colors; chart.WidthRequest = 180; chart.HeightRequest = 180; chart.Series.Add(doughnutSeries); chart.Title.TextColor = Color.FromHex("#cccccc"); chart.HorizontalOptions = LayoutOptions.Center; chart.VerticalOptions = LayoutOptions.Center; ChartGrid.Children.Add(chart); StackLayout MiddleStack = new StackLayout() { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, BackgroundColor = Color.White }; Label MiddleText1 = new Label() { Text = "23%", FontSize = 20, FontAttributes = FontAttributes.Bold }; Label MiddleText2 = new Label() { Text = "mobile", FontSize = 10, FontAttributes = FontAttributes.Bold }; MiddleStack.Children.Add(MiddleText1); MiddleStack.Children.Add(MiddleText2); ChartGrid.Children.Add(MiddleStack); }
private RadPieChartView createChart() { RadPieChartView pieChart = new RadPieChartView(this.Activity); DoughnutSeries doughnutSeries = new DoughnutSeries(); doughnutSeries.ValueBinding = new ValueBinding(); doughnutSeries.ShowLabels = true; doughnutSeries.Data = this.getData(); pieChart.Series.Add(doughnutSeries); return pieChart; }
private RadPieChartView createChart() { RadPieChartView pieChart = new RadPieChartView(this.Activity); DoughnutSeries doughnutSeries = new DoughnutSeries(); doughnutSeries.ValueBinding = new ValueBinding(); doughnutSeries.ShowLabels = true; doughnutSeries.Data = this.getData(); pieChart.Series.Add(doughnutSeries); return(pieChart); }
public void chartSemiDonut(SfChart chart, string xpath, string ypath, string unids, IEnumerable <object> data, string title) { DoughnutSeries doughnutSeries = new DoughnutSeries() { ItemsSource = data, XBindingPath = "Name", YBindingPath = "Height", StartAngle = 180, EndAngle = 360 }; chart.Series.Add(doughnutSeries); charts.Add(chart); }
private void ResetSeries() { this.TotalDownTime = 640; Series series; ObservableCollection <Series> seriesSource = new ObservableCollection <Series>(); series = new ColumnSeries(); series.Title = "Maintenance"; series.Items = _dataManager.GetDownTimeDataBasedOnCauses("Maintenance"); seriesSource.Add(series); series = new ColumnSeries(); series.Title = "Server Failure"; series.Items = _dataManager.GetDownTimeDataBasedOnCauses("Server Failure"); seriesSource.Add(series); series = new ColumnSeries(); series.Title = "Network Failure"; series.Items = _dataManager.GetDownTimeDataBasedOnCauses("Network Failure"); seriesSource.Add(series); series = new LineSeries(); series.Title = "Total DownTime (Minutes)"; series.DataAnnotations.Add(new DataAnnotation("Need Attention", 150, "April", Colors.Red)); series.Items = _dataManager.GetMonthlyTotalDownTimeData(); seriesSource.Add(series); this.Chart.Series = seriesSource; seriesSource = new ObservableCollection <Series>(); series = new DoughnutSeries(); series.Title = "Causes"; series.IsDataLabelVisible = true; ((DoughnutSeries)series).TextFormat = "{PercentageIndependentValue}"; series.Items = _dataManager.GetTotalDownTimeData(); seriesSource.Add(series); this.Chart2.Series = seriesSource; seriesSource = new ObservableCollection <Series>(); series = new BarSeries(); series.StyleSelector = new StyleSelectors(); series.Title = "DownTime Period"; series.Items = _dataManager.GetPeriodicDownTimeData(); seriesSource.Add(series); this.Chart3.Series = seriesSource; }
public override View GetSampleContent(Context context) { var chart = new SfChart(context);; chart.SetBackgroundColor(Color.White); chart.Title.Text = "Products Growth - 2015"; chart.Legend.Visibility = Visibility.Visible; if (context.Resources.DisplayMetrics.HeightPixels > context.Resources.DisplayMetrics.WidthPixels) { int padding = (context.Resources.DisplayMetrics.HeightPixels - context.Resources.DisplayMetrics.WidthPixels) / 2; chart.SetPadding(0, padding / 2, 0, padding); chart.Legend.DockPosition = ChartDock.Bottom; } else { int padding = (context.Resources.DisplayMetrics.WidthPixels - context.Resources.DisplayMetrics.HeightPixels) / 2; chart.SetPadding(padding, 0, padding, 0); chart.Legend.ItemMarginRight = padding / 6; chart.Legend.DockPosition = ChartDock.Right; } var datas = new ObservableArrayList(); datas.Add(new ChartDataPoint("Product A", 14)); datas.Add(new ChartDataPoint("Product B", 54)); datas.Add(new ChartDataPoint("Product C", 23)); datas.Add(new ChartDataPoint("Product D", 53)); var doughnutSeries = new DoughnutSeries { DataSource = datas, StartAngle = 180, EndAngle = 360 }; doughnutSeries.DataMarker.ShowLabel = true; doughnutSeries.DataMarker.LabelContent = LabelContent.Percentage; doughnutSeries.DataMarkerPosition = CircularSeriesDataMarkerPosition.Outside; chart.Series.Add(doughnutSeries); return(chart); }
public override View GetSampleContent(Context context) { chart = new SfChart(context); chart.Title.Text = "Percentage of Loan Closure"; chart.Title.TextSize = 15; chart.SetBackgroundColor(Color.White); chart.Legend.Visibility = Visibility.Visible; chart.Legend.DockPosition = ChartDock.Bottom; chart.Legend.OverflowMode = ChartLegendOverflowMode.Wrap; chart.LegendItemCreated += Chart_LegendItemCreated; density = context.Resources.DisplayMetrics.Density; colors = new List <Color>(); colors.Add(Color.ParseColor("#47ba9f")); colors.Add(Color.ParseColor("#e58870")); colors.Add(Color.ParseColor("#9686c9")); colors.Add(Color.ParseColor("#e56590")); ImageView image = new ImageView(chart.Context); image.LayoutParameters = new ViewGroup.LayoutParams(new LinearLayout.LayoutParams((int)(100 * density), (int)(100 * density))); image.SetImageResource(Resource.Drawable.Person); DoughnutSeries doughnutSeries = new DoughnutSeries(); doughnutSeries.ColorModel.ColorPalette = ChartColorPalette.Custom; doughnutSeries.ColorModel.CustomColors = colors; doughnutSeries.ItemsSource = MainPage.GetStackedDoughnutData(); doughnutSeries.XBindingPath = "XValue"; doughnutSeries.YBindingPath = "YValue"; doughnutSeries.StartAngle = -90; doughnutSeries.EndAngle = 270; doughnutSeries.MaximumValue = 100; doughnutSeries.Spacing = 0.4; doughnutSeries.DoughnutCoefficient = 0.6; doughnutSeries.CircularCoefficient = 0.9; doughnutSeries.IsStackedDoughnut = true; doughnutSeries.CapStyle = DoughnutCapStyle.BothCurve; doughnutSeries.CenterView = image; chart.Series.Add(doughnutSeries); return(chart); }
public override View GetSampleContent(Context context) { var chart = new SfChart(context); ; chart.SetBackgroundColor(Color.White); chart.Title.Text = "Products Growth - 2015"; chart.Legend.Visibility = Visibility.Visible; if (context.Resources.DisplayMetrics.HeightPixels > context.Resources.DisplayMetrics.WidthPixels) { int padding = (context.Resources.DisplayMetrics.HeightPixels - context.Resources.DisplayMetrics.WidthPixels) / 2; chart.SetPadding(0, padding / 2, 0, padding); chart.Legend.DockPosition = ChartDock.Bottom; } else { int padding = (context.Resources.DisplayMetrics.WidthPixels - context.Resources.DisplayMetrics.HeightPixels) / 2; chart.SetPadding(padding, 0, padding, 0); chart.Legend.ItemMarginRight = padding / 6; chart.Legend.DockPosition = ChartDock.Right; } var datas = new ObservableArrayList(); datas.Add(new ChartDataPoint("Product A", 14)); datas.Add(new ChartDataPoint("Product B", 54)); datas.Add(new ChartDataPoint("Product C", 23)); datas.Add(new ChartDataPoint("Product D", 53)); var doughnutSeries = new DoughnutSeries { DataSource = datas, StartAngle = 180, EndAngle = 360 }; doughnutSeries.DataMarker.ShowLabel = true; doughnutSeries.DataMarker.LabelContent = LabelContent.Percentage; doughnutSeries.DataMarkerPosition = CircularSeriesDataMarkerPosition.Outside; chart.Series.Add(doughnutSeries); return chart; }
public override View GetSampleContent(Context context) { var chart = new SfChart(context);; chart.SetBackgroundColor(Color.White); chart.Title.Text = "Products Growth - 2015"; chart.Title.TextSize = 15; chart.Legend.Visibility = Visibility.Visible; chart.Legend.DockPosition = ChartDock.Bottom; chart.Legend.IconHeight = 14; chart.Legend.IconWidth = 14; chart.Legend.ToggleSeriesVisibility = true; var datas = new List <DataPoint>(); datas.Add(new DataPoint("Product A", 14)); datas.Add(new DataPoint("Product B", 54)); datas.Add(new DataPoint("Product C", 23)); datas.Add(new DataPoint("Product D", 53)); var doughnutSeries = new DoughnutSeries { ItemsSource = datas, XBindingPath = "XValue", YBindingPath = "YValue", StartAngle = 180, EndAngle = 360 }; doughnutSeries.ColorModel.ColorPalette = ChartColorPalette.Natural; doughnutSeries.DataMarker.ShowLabel = true; doughnutSeries.DataMarker.LabelContent = LabelContent.Percentage; doughnutSeries.DataMarkerPosition = CircularSeriesDataMarkerPosition.Outside; doughnutSeries.EnableAnimation = true; chart.Series.Add(doughnutSeries); return(chart); }
private void InitializePieChart() { if (chartLayout.Context == null) { return; } pieChart = new SfChart(chartLayout.Context); pieChart.Title.Text = "Coin Distribution"; pieChart.Legend.Visibility = Visibility.Visible; pieChart.Legend.DockPosition = ChartDock.Left; pieChart.Legend.OverflowMode = ChartLegendOverflowMode.Wrap; columnSeriesViewModel = new ColumnSeriesViewModel(); DoughnutSeries doughnutSeries = new DoughnutSeries() { ItemsSource = columnSeriesViewModel.AssetsPerCoin, XBindingPath = "Name", YBindingPath = "Value", DoughnutCoefficient = 0.4f, CircularCoefficient = 0.9f }; doughnutSeries.ColorModel.ColorPalette = ChartColorPalette.Custom; doughnutSeries.ColorModel.CustomColors = GetCustomColorsList(columnSeriesViewModel.AssetsPerCoin); doughnutSeries.DataMarker.LabelContent = LabelContent.Percentage; doughnutSeries.DataMarker.ShowLabel = false; pieChart.Series.Add(doughnutSeries); pieChart.Tag = pieChartTag; pieChart.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); }
public BuyerPage() { InitializeComponent(); DashboardViewModel dvm = new DashboardViewModel(); BindingContext = dvm; int hd = DependencyService.Get <IDisplaySize>().GetHeightDiP(); AbsoluteLayout.SetLayoutBounds(SideMenuOverlay, new Rectangle(0, 0, 0.9, hd - 20)); SfChart chart = new SfChart(); DoughnutSeries doughnutSeries = new DoughnutSeries() { ItemsSource = dvm.ChartData, XBindingPath = "Name", YBindingPath = "Value", DoughnutCoefficient = 0.7, ExplodeIndex = 0 }; List <Color> colors = new List <Color>() { Color.FromHex("#82DA69"), Color.FromHex("#E47132"), Color.FromHex("#9EE5FC"), }; doughnutSeries.ColorModel.Palette = ChartColorPalette.Custom; doughnutSeries.ColorModel.CustomBrushes = colors; chart.WidthRequest = 180; chart.HeightRequest = 180; //chart.BackgroundColor = Color.FromHex("#F3F3F3"); chart.Series.Add(doughnutSeries); chart.Title.TextColor = Color.FromHex("#cccccc"); chart.HorizontalOptions = LayoutOptions.Center; chart.VerticalOptions = LayoutOptions.Center; ChartGrid.Children.Add(chart); StackLayout MiddleStack = new StackLayout() { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, BackgroundColor = Color.White }; Label MiddleText1 = new Label() { Text = "23%", FontSize = 20, FontAttributes = FontAttributes.Bold }; Label MiddleText2 = new Label() { Text = "mobile", FontSize = 10, FontAttributes = FontAttributes.Bold }; MiddleStack.Children.Add(MiddleText1); MiddleStack.Children.Add(MiddleText2); ChartGrid.Children.Add(MiddleStack); BuyerViewModel bvm = new BuyerViewModel(); this.BindingContext = bvm; TransactionsListView.ItemsSource = bvm.TransactionsData; //Slide menu creating SlideMenu = ((App)Application.Current).SideMenu; //Toolbar taps TapGestureRecognizer ToolbarTap1 = new TapGestureRecognizer(); ToolbarTap1.Tapped += (s, e) => { this.ShowMenu(); }; Menu.GestureRecognizers.Add(ToolbarTap1); TapGestureRecognizer ToolbarTap2 = new TapGestureRecognizer(); ToolbarTap2.Tapped += (s, e) => { SearchPage sp = new SearchPage(); Application.Current.MainPage.Navigation.PushAsync(sp); }; Search.GestureRecognizers.Add(ToolbarTap2); //In page navigation TapGestureRecognizer InPageNavigationTap2 = new TapGestureRecognizer(); InPageNavigationTap2.Tapped += (s, e) => { BuyerRankingsPage brp = new BuyerRankingsPage(); Application.Current.MainPage.Navigation.PushAsync(brp); }; Ranks.GestureRecognizers.Add(InPageNavigationTap2); RanksLabel.GestureRecognizers.Add(InPageNavigationTap2); TapGestureRecognizer InPageNavigationTap3 = new TapGestureRecognizer(); InPageNavigationTap3.Tapped += (s, e) => { LatePaymentsPage lpp = new LatePaymentsPage(); Application.Current.MainPage.Navigation.PushAsync(lpp); }; LatePayments.GestureRecognizers.Add(InPageNavigationTap3); LatePaymentsLabel.GestureRecognizers.Add(InPageNavigationTap3); RanksLabel.GestureRecognizers.Add(InPageNavigationTap2); }
private void GenerateData() { this.TotalDownTime = 640; Series series; //Chart 1 this.Chart = new Chart(); this.Chart.Title.Text = "Website Downtime (Minutes)"; this.Chart.Title.Font = new Font(".HelveticaNeueInterface-Light,14;Roboto,14,Bold"); series = new ColumnSeries(); series.Title = "Maintenance"; series.Items = _dataManager.GetDownTimeDataBasedOnCauses("Maintenance"); this.Chart.Series.Add(series); series = new ColumnSeries(); series.Title = "Server Failure"; series.Items = _dataManager.GetDownTimeDataBasedOnCauses("Server Failure"); this.Chart.Series.Add(series); series = new ColumnSeries(); series.Title = "Network Failure"; series.Items = _dataManager.GetDownTimeDataBasedOnCauses("Network Failure"); this.Chart.Series.Add(series); series = new LineSeries(); series.Title = "Total DownTime (Minutes)"; series.DataAnnotations.Add(new DataAnnotation("Need Attention", 150, "April", Colors.Red)); series.Items = _dataManager.GetMonthlyTotalDownTimeData(); this.Chart.Series.Add(series); NumericAxis independentAxis = Axis.CreateDefaultIndependentAxis <NumericAxis>(); CategoryAxis dependentAxis = Axis.CreateDefaultDependentAxis <CategoryAxis>(); this.Chart.IndependentAxis = independentAxis; this.Chart.DependentAxis = dependentAxis; this.Chart.ColorPalette.PaletteOrder = PaletteOrders.Random; //Chart 2 this.Chart2 = new Chart(); this.Chart2.Title.Text = "Causes"; this.Chart2.Title.Font = new Font(".HelveticaNeueInterface-Light,14;Roboto,14,Bold"); this.Chart2.ColorPalette.Palette = PaletteTypes.Pastel; series = new DoughnutSeries(); series.Title = "Causes"; series.IsDataLabelVisible = true; ((DoughnutSeries)series).TextFormat = "{PercentageIndependentValue}"; series.Items = _dataManager.GetTotalDownTimeData(); this.Chart2.Series.Add(series); independentAxis = Axis.CreateDefaultIndependentAxis <NumericAxis>(); dependentAxis = Axis.CreateDefaultDependentAxis <CategoryAxis>(); this.Chart2.IndependentAxis = independentAxis; this.Chart2.DependentAxis = dependentAxis; //Chart 3 this.Chart3 = new Chart(); this.Chart3.Title.Text = "Period"; this.Chart3.Title.Font = new Font(".HelveticaNeueInterface-Light,14;Roboto,14,Bold"); series = new BarSeries(); series.StyleSelector = new StyleSelectors(); series.Title = "DownTime Period"; series.Items = _dataManager.GetPeriodicDownTimeData(); this.Chart3.Series.Add(series); independentAxis = Axis.CreateDefaultIndependentAxis <NumericAxis>(); dependentAxis = Axis.CreateDefaultDependentAxis <CategoryAxis>(); this.Chart3.IndependentAxis = independentAxis; this.Chart3.DependentAxis = dependentAxis; this.Chart3.Legend.Visibility = Visibility.Collapsed; }
private void OnChartTypeSelectionChanged1(object sender, SelectionChangedEventArgs e) { ComboBox comboBox = sender as ComboBox; if (comboBox.SelectedIndex == 0 && viewModel != null) { if (Accumulation_charts != null) { Accumulation_charts.Header = "Agriculture Expenses Comparison"; PieSeries series1 = new PieSeries(); DataTemplate template1 = MainGrid.Resources["labelTemplate"] as DataTemplate; ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); adornmentInfo1.ShowLabel = true; ChartLegend1.Visibility = Visibility.Visible; series1.XBindingPath = "Expense"; series1.YBindingPath = "Amount"; series1.ItemsSource = viewModel.Expenditure; series1.ConnectorType = ConnectorMode.Bezier; series1.PieCoefficient = 0.7; series1.EnableSmartLabels = true; series1.LabelPosition = CircularSeriesLabelPosition.OutsideExtended; adornmentInfo1.LabelTemplate = template1; adornmentInfo1.AdornmentsPosition = AdornmentsPosition.Bottom; adornmentInfo1.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; adornmentInfo1.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center; adornmentInfo1.ShowConnectorLine = true; adornmentInfo1.ConnectorHeight = 80; adornmentInfo1.ShowLabel = true; adornmentInfo1.UseSeriesPalette = true; adornmentInfo1.SegmentLabelContent = LabelContent.LabelContentPath; series1.AdornmentsInfo = adornmentInfo1; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } } if (comboBox.SelectedIndex == 2 && viewModel != null) { Accumulation_charts.Header = "Top car company's turnover"; DoughnutSeries series1 = new DoughnutSeries(); DataTemplate template1 = MainGrid.Resources["labeltemplate"] as DataTemplate; ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); adornmentInfo1.ShowLabel = true; ChartLegend1.Visibility = Visibility.Visible; series1.XBindingPath = "CompanyName"; series1.YBindingPath = "CompanyTurnover"; series1.ItemsSource = viewModel.CompanyDetails; adornmentInfo1.LabelTemplate = template1; series1.AdornmentsInfo = adornmentInfo1; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } if (comboBox.SelectedIndex == 4 && viewModel != null) { Accumulation_charts.Header = "Top car company's turnover"; Accumulation_charts.Margin = new Thickness(20, 20, 20, 20); PyramidSeries series1 = new PyramidSeries(); series1.Margin = new Thickness(20, 0, 20, 20); DataTemplate template1 = MainGrid.Resources["labelTemplate"] as DataTemplate; ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); adornmentInfo1.ShowLabel = true; ChartLegend1.Visibility = Visibility.Collapsed; series1.XBindingPath = "CompanyName"; series1.YBindingPath = "CompanyTurnover"; series1.ItemsSource = viewModel.CompanyDetails; adornmentInfo1.LabelTemplate = template1; series1.AdornmentsInfo = adornmentInfo1; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } if (comboBox.SelectedIndex == 5 && viewModel != null) { Accumulation_charts.Header = "Top car company's turnover"; Accumulation_charts.Margin = new Thickness(20, 20, 20, 20); FunnelSeries series1 = new FunnelSeries(); series1.Margin = new Thickness(20, 0, 20, 20); DataTemplate template1 = MainGrid.Resources["labelTemplate"] as DataTemplate; ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); adornmentInfo1.ShowLabel = true; ChartLegend1.Visibility = Visibility.Collapsed; series1.XBindingPath = "CompanyName"; series1.YBindingPath = "CompanyTurnover"; series1.ItemsSource = viewModel.CompanyDetails; adornmentInfo1.LabelTemplate = template1; series1.AdornmentsInfo = adornmentInfo1; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } if (comboBox.SelectedIndex == 1 && viewModel != null) { Accumulation_charts.Header = "Application Performance Metrics"; ChartLegend1.Visibility = Visibility.Collapsed; PieSeries series1 = new PieSeries(); series1.Margin = new Thickness(0, 25, 0, 0); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); adornmentInfo1.ShowLabel = true; adornmentInfo1.ShowConnectorLine = true; adornmentInfo1.UseSeriesPalette = true; adornmentInfo1.ConnectorHeight = 37; adornmentInfo1.SegmentLabelContent = LabelContent.Percentage; adornmentInfo1.SegmentLabelFormat = "##.#"; series1.XBindingPath = "Utilization"; series1.YBindingPath = "ResponseTime"; series1.StartAngle = 180; series1.EndAngle = 360; series1.ConnectorType = ConnectorMode.Bezier; series1.EnableSmartLabels = true; series1.LabelPosition = CircularSeriesLabelPosition.Outside; series1.ItemsSource = viewModel.Metric; series1.AdornmentsInfo = adornmentInfo1; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } if (comboBox.SelectedIndex == 3 && viewModel != null) { Accumulation_charts.Header = "Application Performance Metrics"; ChartLegend1.Visibility = Visibility.Collapsed; DoughnutSeries series1 = new DoughnutSeries(); series1.Margin = new Thickness(0, 25, 0, 0); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); adornmentInfo1.ShowLabel = true; adornmentInfo1.ShowConnectorLine = true; adornmentInfo1.UseSeriesPalette = true; adornmentInfo1.ConnectorHeight = 37; adornmentInfo1.SegmentLabelContent = LabelContent.Percentage; adornmentInfo1.SegmentLabelFormat = "##.#"; series1.XBindingPath = "Utilization"; series1.YBindingPath = "ResponseTime"; series1.StartAngle = 180; series1.EndAngle = 360; series1.ConnectorType = ConnectorMode.Bezier; series1.EnableSmartLabels = true; series1.LabelPosition = CircularSeriesLabelPosition.Outside; series1.ItemsSource = viewModel.Metric; series1.AdornmentsInfo = adornmentInfo1; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } }
public ExpensesPage() { InitializeComponent(); ExpensesViewModel evm = new ExpensesViewModel(); BindingContext = evm; int hd = DependencyService.Get <IDisplaySize>().GetHeightDiP(); int wd = DependencyService.Get <IDisplaySize>().GetWidthDiP(); AbsoluteLayout.SetLayoutBounds(SideMenuOverlay, new Rectangle(0, 0, 0.9, hd - 20)); Category1.Source = ImageSource.FromResource("Tulsi.Images.yellowcategory.png"); Category2.Source = ImageSource.FromResource("Tulsi.Images.lightbluecategory.png"); Category3.Source = ImageSource.FromResource("Tulsi.Images.bluecategory.png"); Category4.Source = ImageSource.FromResource("Tulsi.Images.magentacategory.png"); Category5.Source = ImageSource.FromResource("Tulsi.Images.pinkcategory.png"); Category6.Source = ImageSource.FromResource("Tulsi.Images.lightgreencategory.png"); Category7.Source = ImageSource.FromResource("Tulsi.Images.greencategory.png"); Category8.Source = ImageSource.FromResource("Tulsi.Images.browncategory.png"); Category9.Source = ImageSource.FromResource("Tulsi.Images.graycategory.png"); Category10.Source = ImageSource.FromResource("Tulsi.Images.graycategory.png"); Category11.Source = ImageSource.FromResource("Tulsi.Images.graycategory.png"); Category12.Source = ImageSource.FromResource("Tulsi.Images.graycategory.png"); Category13.Source = ImageSource.FromResource("Tulsi.Images.graycategory.png"); Category14.Source = ImageSource.FromResource("Tulsi.Images.graycategory.png"); Category15.Source = ImageSource.FromResource("Tulsi.Images.graycategory.png"); BlueCircleTab.Source = ImageSource.FromResource("Tulsi.Images.tabbluecircle.png"); EmptyCircleTab.Source = ImageSource.FromResource("Tulsi.Images.emptycircle.png"); More.Source = ImageSource.FromResource("Tulsi.Images.3whitecircles.png"); SfChart chart = new SfChart(); DoughnutSeries doughnutSeries = new DoughnutSeries() { ItemsSource = evm.ChartData, XBindingPath = "Name", YBindingPath = "Value", DoughnutCoefficient = 0.7, }; doughnutSeries.DataMarker = new ChartDataMarker(); List <Color> colors = new List <Color>() { Color.FromHex("#F5DB67"), Color.FromHex("#9EE5FD"), Color.FromHex("#74C9FA"), Color.FromHex("#D76DC8"), Color.FromHex("#F8A5C3"), Color.FromHex("#82DA69"), Color.FromHex("#54CD33"), Color.FromHex("#E57233"), }; doughnutSeries.ColorModel.Palette = ChartColorPalette.Custom; doughnutSeries.ColorModel.CustomBrushes = colors; chart.Series.Add(doughnutSeries); chart.HorizontalOptions = LayoutOptions.Center; chart.VerticalOptions = LayoutOptions.Center; //chart.BackgroundColor = Color.FromHex("#F3F3F3"); chart.WidthRequest = wd; ChartGrid.Children.Add(chart); StackLayout MiddleStack = new StackLayout() { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, BackgroundColor = Color.White, }; Label MiddleText0 = new Label() { Text = "100%", FontSize = 14, HorizontalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold, BackgroundColor = Color.White }; Label MiddleText1 = new Label() { Text = "2,468.40", FontSize = 25, HorizontalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }; Label MiddleText2 = new Label() { Text = "USD", FontSize = 14, HorizontalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }; MiddleStack.Children.Add(MiddleText0); MiddleStack.Children.Add(MiddleText1); MiddleStack.Children.Add(MiddleText2); // MiddleStack.BackgroundColor = Color.Transparent; ChartGrid.Children.Add(MiddleStack); //Toolbar taps TapGestureRecognizer tapGestureRecognizer1 = new TapGestureRecognizer(); tapGestureRecognizer1.Tapped += (s, e) => { SideMenuOverlay.IsVisible = true; OutsideOverlay.IsVisible = true; }; Menu.GestureRecognizers.Add(tapGestureRecognizer1); TapGestureRecognizer tapGestureRecognizer2 = new TapGestureRecognizer(); tapGestureRecognizer2.Tapped += (s, e) => { SideMenuOverlay.IsVisible = false; OutsideOverlay.IsVisible = false; }; OutsideOverlay.GestureRecognizers.Add(tapGestureRecognizer2); TapGestureRecognizer tapGestureRecognizer3 = new TapGestureRecognizer(); tapGestureRecognizer3.Tapped += (s, e) => { SideMenuOverlay.IsVisible = false; OutsideOverlay.IsVisible = false; }; SideMenuHeaderCloseIcon.GestureRecognizers.Add(tapGestureRecognizer3); //In page navigation TapGestureRecognizer InPageNavigationTap1 = new TapGestureRecognizer(); InPageNavigationTap1.Tapped += (s, e) => { ExpensesListPage elp = new ExpensesListPage(); Application.Current.MainPage.Navigation.PushAsync(elp); }; ExpensesExtraIcon.GestureRecognizers.Add(InPageNavigationTap1); }
private void OnChartTypeSelectionChanged1(object sender, SelectionChangedEventArgs e) { ComboBox comboBox = sender as ComboBox; Accumulation_charts.Legend = null; if (comboBox.SelectedIndex == 0 && viewModel != null) { if (Accumulation_charts != null) { if (Accumulation_charts.Legend == null) { Accumulation_charts.Legend = new ChartLegend() { CornerRadius = new CornerRadius(0), FontSize = 15, DockPosition = ChartDock.Right, BorderThickness = new Thickness(1) }; } PieSeries series1 = new PieSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartLegend1.Visibility = Visibility.Visible; DataTemplate template1 = MainGrid.Resources["labelTemplate"] as DataTemplate; adornmentInfo1.ShowLabel = true; adornmentInfo1.LabelTemplate = template1; adornmentInfo1.AdornmentsPosition = AdornmentsPosition.Bottom; adornmentInfo1.HorizontalAlignment = HorizontalAlignment.Center; adornmentInfo1.VerticalAlignment = VerticalAlignment.Center; adornmentInfo1.ShowConnectorLine = true; adornmentInfo1.ConnectorHeight = 80; adornmentInfo1.ShowLabel = true; adornmentInfo1.UseSeriesPalette = true; adornmentInfo1.SegmentLabelContent = LabelContent.LabelContentPath; series1.XBindingPath = "Countries"; series1.YBindingPath = "Count"; series1.ItemsSource = viewModel.CountryDetails; series1.PieCoefficient = 0.7; series1.EnableSmartLabels = true; series1.LabelPosition = CircularSeriesLabelPosition.OutsideExtended; series1.AdornmentsInfo = adornmentInfo1; series1.GroupMode = PieGroupMode.Value; series1.GroupTo = 1000; Accumulation_charts.Header = "Agriculture Expenses Comparison"; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } } if (comboBox.SelectedIndex == 1 && viewModel != null) { PieSeries series1 = new PieSeries(); PieSeries series2 = new PieSeries(); PieSeries series3 = new PieSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartAdornmentInfo adornmentInfo2 = new ChartAdornmentInfo(); ChartAdornmentInfo adornmentInfo3 = new ChartAdornmentInfo(); ChartColorModel color1 = new ChartColorModel(); ChartColorModel color2 = new ChartColorModel(); ChartColorModel color3 = new ChartColorModel(); color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); DataTemplate template1 = MainGrid.Resources["populationLabelTemplate1"] as DataTemplate; DataTemplate template2 = MainGrid.Resources["populationLabelTemplate2"] as DataTemplate; DataTemplate template3 = MainGrid.Resources["populationLabelTemplate3"] as DataTemplate; ChartLegend1.Visibility = Visibility.Collapsed; adornmentInfo1.ShowLabel = true; adornmentInfo1.SegmentLabelContent = LabelContent.LabelContentPath; adornmentInfo1.LabelTemplate = template1; adornmentInfo2.ShowLabel = true; adornmentInfo2.SegmentLabelContent = LabelContent.LabelContentPath; adornmentInfo2.LabelTemplate = template2; adornmentInfo3.ShowLabel = true; adornmentInfo3.SegmentLabelContent = LabelContent.LabelContentPath; adornmentInfo3.LabelTemplate = template3; series1.ItemsSource = viewModel.Population; series1.XBindingPath = "Continent"; series1.YBindingPath = "PopulationinContinents"; series1.AdornmentsInfo = adornmentInfo1; series1.Stroke = new SolidColorBrush(Colors.White); series1.PieCoefficient = 1; series1.Label = "Continents"; series1.Palette = ChartColorPalette.Custom; series1.ColorModel = color1; series2.ItemsSource = viewModel.Population; series2.XBindingPath = "Countries"; series2.YBindingPath = "PopulationinCountries"; series2.AdornmentsInfo = adornmentInfo2; series2.Stroke = new SolidColorBrush(Colors.White); series2.PieCoefficient = 1; series2.Label = "Countries"; series2.Palette = ChartColorPalette.Custom; series2.ColorModel = color2; series3.ItemsSource = viewModel.Population; series3.XBindingPath = "States"; series3.YBindingPath = "PopulationinStates"; series3.AdornmentsInfo = adornmentInfo3; series3.Stroke = new SolidColorBrush(Colors.White); series3.PieCoefficient = 1; series3.Label = "States"; series3.Palette = ChartColorPalette.Custom; series3.ColorModel = color3; Accumulation_charts.Header = "Most populated continents"; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); Accumulation_charts.Series.Add(series2); Accumulation_charts.Series.Add(series3); } if (comboBox.SelectedIndex == 2 && viewModel != null) { PieSeries series1 = new PieSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartLegend1.Visibility = Visibility.Collapsed; series1.Margin = new Thickness(0, 25, 0, 0); adornmentInfo1.ShowLabel = true; adornmentInfo1.ShowConnectorLine = true; adornmentInfo1.UseSeriesPalette = true; adornmentInfo1.ConnectorHeight = 37; adornmentInfo1.SegmentLabelContent = LabelContent.Percentage; adornmentInfo1.SegmentLabelFormat = "##.#"; series1.XBindingPath = "Utilization"; series1.YBindingPath = "ResponseTime"; series1.StartAngle = 180; series1.EndAngle = 360; series1.EnableSmartLabels = true; series1.LabelPosition = CircularSeriesLabelPosition.Outside; series1.ItemsSource = viewModel.Metric; series1.AdornmentsInfo = adornmentInfo1; Accumulation_charts.Header = "Application Performance Metrics"; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } if (comboBox.SelectedIndex == 3 && viewModel != null) { if (Accumulation_charts.Legend == null) { Accumulation_charts.Legend = new ChartLegend() { CornerRadius = new CornerRadius(0), FontSize = 15, DockPosition = ChartDock.Right, BorderThickness = new Thickness(1) }; } DoughnutSeries series1 = new DoughnutSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartLegend1.Visibility = Visibility.Visible; DataTemplate template1 = MainGrid.Resources["labeltemplate"] as DataTemplate; adornmentInfo1.ShowLabel = true; adornmentInfo1.LabelTemplate = template1; series1.XBindingPath = "CompanyName"; series1.YBindingPath = "CompanyTurnover"; series1.ItemsSource = viewModel.CompanyDetails; series1.AdornmentsInfo = adornmentInfo1; Accumulation_charts.Series.Clear(); Accumulation_charts.Header = "Top car company's turnover"; Accumulation_charts.Series.Add(series1); } if (comboBox.SelectedIndex == 4 && viewModel != null) { DoughnutSeries series1 = new DoughnutSeries(); DoughnutSeries series2 = new DoughnutSeries(); DoughnutSeries series3 = new DoughnutSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartAdornmentInfo adornmentInfo2 = new ChartAdornmentInfo(); ChartAdornmentInfo adornmentInfo3 = new ChartAdornmentInfo(); ChartColorModel color1 = new ChartColorModel(); ChartColorModel color2 = new ChartColorModel(); ChartColorModel color3 = new ChartColorModel(); color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); DataTemplate template1 = MainGrid.Resources["populationLabelTemplate1"] as DataTemplate; DataTemplate template2 = MainGrid.Resources["populationLabelTemplate2"] as DataTemplate; DataTemplate template3 = MainGrid.Resources["populationLabelTemplate3"] as DataTemplate; ChartLegend1.Visibility = Visibility.Collapsed; adornmentInfo1.ShowLabel = true; adornmentInfo1.SegmentLabelContent = LabelContent.LabelContentPath; adornmentInfo1.LabelTemplate = template1; adornmentInfo2.ShowLabel = true; adornmentInfo2.SegmentLabelContent = LabelContent.LabelContentPath; adornmentInfo2.LabelTemplate = template2; adornmentInfo3.ShowLabel = true; adornmentInfo3.SegmentLabelContent = LabelContent.LabelContentPath; adornmentInfo3.LabelTemplate = template3; series1.ItemsSource = viewModel.Population; series1.XBindingPath = "Continent"; series1.YBindingPath = "PopulationinContinents"; series1.AdornmentsInfo = adornmentInfo1; series1.Stroke = new SolidColorBrush(Colors.White); series1.DoughnutCoefficient = 1; series1.DoughnutSize = 1; series1.Label = "Continents"; series1.Palette = ChartColorPalette.Custom; series1.ColorModel = color1; series2.ItemsSource = viewModel.Population; series2.XBindingPath = "Countries"; series2.YBindingPath = "PopulationinCountries"; series2.AdornmentsInfo = adornmentInfo2; series2.Stroke = new SolidColorBrush(Colors.White); series2.DoughnutCoefficient = 1; series2.DoughnutSize = 1; series2.Label = "Countries"; series2.Palette = ChartColorPalette.Custom; series2.ColorModel = color2; series3.ItemsSource = viewModel.Population; series3.XBindingPath = "States"; series3.YBindingPath = "PopulationinStates"; series3.AdornmentsInfo = adornmentInfo3; series3.Stroke = new SolidColorBrush(Colors.White); series3.DoughnutCoefficient = 1; series3.DoughnutSize = 1; series3.Label = "States"; series3.Palette = ChartColorPalette.Custom; series3.ColorModel = color3; Accumulation_charts.Header = "Most populated continents"; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); Accumulation_charts.Series.Add(series2); Accumulation_charts.Series.Add(series3); } if (comboBox.SelectedIndex == 5 && viewModel != null) { DoughnutSeries series1 = new DoughnutSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartLegend1.Visibility = Visibility.Collapsed; adornmentInfo1.ShowLabel = true; adornmentInfo1.ShowConnectorLine = true; adornmentInfo1.UseSeriesPalette = true; adornmentInfo1.ConnectorHeight = 37; adornmentInfo1.SegmentLabelContent = LabelContent.Percentage; adornmentInfo1.SegmentLabelFormat = "##.#"; series1.XBindingPath = "Utilization"; series1.YBindingPath = "ResponseTime"; series1.StartAngle = 180; series1.EndAngle = 360; series1.EnableSmartLabels = true; series1.LabelPosition = CircularSeriesLabelPosition.Outside; series1.Margin = new Thickness(0, 25, 0, 0); series1.ItemsSource = viewModel.Metric; series1.AdornmentsInfo = adornmentInfo1; Accumulation_charts.Header = "Application Performance Metrics"; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } if (comboBox.SelectedIndex == 6 && viewModel != null) { DoughnutSeries doughnutSeries = new DoughnutSeries(); doughnutSeries.DataContext = viewModel; doughnutSeries.XBindingPath = "XValue"; doughnutSeries.YBindingPath = "YValue"; doughnutSeries.ItemsSource = (doughnutSeries.DataContext as PieChartViewModel).DoughnutSeriesData; doughnutSeries.IsStackedDoughnut = true; doughnutSeries.EnableAnimation = true; doughnutSeries.LegendIcon = ChartLegendIcon.Circle; doughnutSeries.StartAngle = -90; doughnutSeries.EndAngle = 270; doughnutSeries.SegmentSpacing = 0.2; doughnutSeries.DoughnutCoefficient = 0.8; doughnutSeries.CapStyle = DoughnutCapStyle.BothCurve; doughnutSeries.MaximumValue = 100; var colorModel = new ChartColorModel(); var customBrushes = new List <Brush>(); customBrushes.Add(new SolidColorBrush(Color.FromArgb(0xFF, 0x47, 0xBA, 0x9F))); customBrushes.Add(new SolidColorBrush(Color.FromArgb(0xFF, 0xE5, 0x88, 0x70))); customBrushes.Add(new SolidColorBrush(Color.FromArgb(0xFF, 0x96, 0x86, 0xC9))); customBrushes.Add(new SolidColorBrush(Color.FromArgb(0xFF, 0xE5, 0x65, 0x90))); colorModel.CustomBrushes = customBrushes; doughnutSeries.ColorModel = colorModel; doughnutSeries.Palette = ChartColorPalette.Custom; var image = new Image() { Source = new BitmapImage(new Uri("ms-appx:///Chart/Tutorials/ChartSamples/PieChart/Images/Person.png", UriKind.RelativeOrAbsolute)) }; var centerView = new ContentControl() { Content = image, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; var binding = new Binding(); binding.Source = doughnutSeries; binding.Path = new PropertyPath("InnerRadius"); binding.Converter = new ImageSizeConverter(); binding.ConverterParameter = doughnutSeries; binding.Mode = BindingMode.TwoWay; centerView.SetBinding(ContentControl.WidthProperty, binding); centerView.SetBinding(ContentControl.HeightProperty, binding); doughnutSeries.CenterView = centerView; var legend = new ChartLegend() { DockPosition = ChartDock.Bottom }; legend.ItemTemplate = MainGrid.Resources["stackedDoughnutTemplate"] as DataTemplate; Accumulation_charts.Legend = legend; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(doughnutSeries); Accumulation_charts.Header = "Percentage of Loan Closure"; } if (comboBox.SelectedIndex == 7 && viewModel != null) { PyramidSeries series1 = new PyramidSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartLegend1.Visibility = Visibility.Collapsed; DataTemplate template1 = MainGrid.Resources["labelTemplate"] as DataTemplate; adornmentInfo1.ShowLabel = true; adornmentInfo1.LabelTemplate = template1; series1.XBindingPath = "CompanyName"; series1.YBindingPath = "CompanyTurnover"; series1.ItemsSource = viewModel.CompanyDetails; series1.AdornmentsInfo = adornmentInfo1; series1.Margin = new Thickness(20, 0, 20, 20); Accumulation_charts.Header = "Top car company's turnover"; Accumulation_charts.Margin = new Thickness(20, 20, 20, 20); Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } if (comboBox.SelectedIndex == 8 && viewModel != null) { FunnelSeries series1 = new FunnelSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartLegend1.Visibility = Visibility.Collapsed; DataTemplate template1 = MainGrid.Resources["labelTemplate"] as DataTemplate; adornmentInfo1.ShowLabel = true; adornmentInfo1.LabelTemplate = template1; series1.XBindingPath = "CompanyName"; series1.YBindingPath = "CompanyTurnover"; series1.ItemsSource = viewModel.CompanyDetails; series1.AdornmentsInfo = adornmentInfo1; series1.Margin = new Thickness(20, 0, 20, 20); Accumulation_charts.Header = "Top car company's turnover"; Accumulation_charts.Margin = new Thickness(20, 20, 20, 20); Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } }
void Chart_LegendItemCreated(object sender, ChartLegendItemCreatedEventArgs e) { MultipleCircleModel datamodel = e.LegendItem.DataPoint as MultipleCircleModel; LinearLayout outerLayout = new LinearLayout(chart.Context); outerLayout.Orientation = Orientation.Horizontal; outerLayout.SetBackgroundColor(Color.Transparent); LinearLayout innerLayout = new LinearLayout(chart.Context); innerLayout.Orientation = Orientation.Vertical; innerLayout.SetPadding(3, 30, 3, 0); innerLayout.SetBackgroundColor(Color.Transparent); TextView loanName = new TextView(chart.Context); TextView loanPercent = new TextView(chart.Context); ImageView centerView = new ImageView(chart.Context); centerView.LayoutParameters = new ViewGroup.LayoutParams(new LinearLayout.LayoutParams((int)(40 * density), (int)(40 * density))); centerView.SetImageResource(datamodel.ImageResId); loanPercent.Text = (e.LegendItem.DataPoint as MultipleCircleModel).YValue + "%"; loanPercent.TextAlignment = Android.Views.TextAlignment.Center; loanPercent.Gravity = GravityFlags.Center; loanPercent.SetTextColor(e.LegendItem.IconColor); loanPercent.TextSize = 15; loanName.Text = (e.LegendItem.DataPoint as MultipleCircleModel).XValue; loanName.TextAlignment = Android.Views.TextAlignment.Center; loanName.Gravity = GravityFlags.Center; loanName.SetTextColor(Color.Black); innerLayout.AddView(loanPercent); innerLayout.AddView(loanName); SfChart sfChart = new SfChart(chart.Context); sfChart.LayoutParameters = new ViewGroup.LayoutParams(new LinearLayout.LayoutParams((int)(65 * density), (int)(65 * density))); sfChart.SetBackgroundColor(Color.White); DoughnutSeries series = new DoughnutSeries(); series.Color = e.LegendItem.IconColor; series.ItemsSource = new ObservableCollection <MultipleCircleModel>() { datamodel }; series.XBindingPath = "XValue"; series.YBindingPath = "YValue"; series.StartAngle = -90; series.EndAngle = 270; series.MaximumValue = 100; series.Spacing = 0.4; series.DoughnutCoefficient = 0.6; series.CircularCoefficient = 0.9; series.CapStyle = DoughnutCapStyle.BothCurve; series.IsStackedDoughnut = true; series.CenterView = centerView; sfChart.Series.Add(series); outerLayout.AddView(sfChart); outerLayout.AddView(innerLayout); e.LegendItem.View = outerLayout; }
private async void GetChart() { SfChart chart = new SfChart() { Legend = new ChartLegend(){ DockPosition = LegendPlacement.Bottom } }; chart.Legend.LabelStyle.Font = Font.SystemFontOfSize(GlobalParameters.LEGEND_TEXT_SIZE_SERIES_, FontAttributes.None); ObservableCollection<ChartDataPoint> datas = new ObservableCollection<ChartDataPoint>(); //pie_ = new PieSeries(); pie_ = new DoughnutSeries(){ StartAngle = GlobalParameters.START_ANGLE_PIE_SERIE, EndAngle = GlobalParameters.END_ANGLE_PIE_SERIE, ExplodeIndex = 1, //EnableSmartLabels = true }; //pie_.ExplodeOnTouch = true; pie_.ItemsSource = datas; pie_.LegendIcon = ChartLegendIcon.Diamond; //Appearance pie_.ColorModel.Palette = ChartColorPalette.Custom; pie_.ColorModel.CustomBrushes = GlobalParameters.COLORS_GRAPHIC01; pie_.DataMarkerPosition = CircularSeriesDataMarkerPosition.OutsideExtended; pie_.ConnectorLineType = ConnectorLineType.Line; pie_.DataMarker = new ChartDataMarker (); pie_.DataMarker.ShowMarker = true; pie_.DataMarker.MarkerWidth = 5; pie_.DataMarker.LabelContent = LabelContent.Percentage; pie_.DataMarker.LabelStyle.Font = Font.SystemFontOfSize(15); pie_.EnableDataPointSelection = true; chart.ChartBehaviors.Add(new ChartZoomPanBehavior(){ EnablePanning = true, EnableZooming = true}) ; chart.VerticalOptions = LayoutOptions.FillAndExpand; chart.HorizontalOptions = LayoutOptions.FillAndExpand; chart.Series.Add(pie_); ////////////// Picker# /// /// Picker Period p_list_period_ = new Picker { Title = "Periodo", VerticalOptions = LayoutOptions.StartAndExpand, Scale = GlobalParameters.SCALE_PICKER, WidthRequest = GlobalParameters.WIDTH_PICKER_PERIODO }; /// Picker Anio p_list_year_ = new Picker { Title = "Año", VerticalOptions = LayoutOptions.StartAndExpand, Scale = GlobalParameters.SCALE_PICKER, WidthRequest = GlobalParameters.WIDTH_PICKER_ANIO }; /// Picker zona p_list_zone_ = new Picker { Title = "Zona", VerticalOptions = LayoutOptions.StartAndExpand, Scale = GlobalParameters.SCALE_PICKER, WidthRequest = GlobalParameters.WIDTH_PICKER_ZONE }; p_list_year_.SelectedIndexChanged += (sender, args) => { if (p_list_year_.SelectedIndex == -1){ pie_.ItemsSource = datas; } else { LoadZones(); } }; p_list_zone_.SelectedIndexChanged += (sender, args) => { if ( p_list_zone_.SelectedIndex == -1 ){ pie_.ItemsSource = datas; }else{ LoadPeriodos( false ); } }; p_list_period_.SelectedIndexChanged += ( sender, args) => { if (p_list_period_.SelectedIndex == -1) { pie_.ItemsSource = datas; } else { LoadGrafico01 (false); } }; labelExploratoria = new Label (){ Text = "0", FontSize = GlobalParameters.LABEL_TEXT_SIZE_15_, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Start }; labelTemporada = new Label (){ Text = "0", FontSize = GlobalParameters.LABEL_TEXT_SIZE_15_, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center }; labelSaldo = new Label (){ Text = "0", FontSize = GlobalParameters.LABEL_TEXT_SIZE_15_, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.End }; StackLayout main_layout = new StackLayout (){ Padding = GlobalParameters.MAIN_LAYOUT_PADDING_, Spacing = 0, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Vertical, Children = { //pmenu_pesquera_, indicator, new Label(){ Text = "AVANCE PESCA POR ZONA", HorizontalOptions = LayoutOptions.Center }, new StackLayout(){ Spacing = 0, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Children = { new Label(){ Text = "Año: ", FontSize = GlobalParameters.LABEL_TEXT_SIZE_15_, VerticalOptions = LayoutOptions.Center }, p_list_year_, new StackLayout{ Spacing = 0, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Horizontal, Children = { new Label(){ Text = "Zona: ", FontSize = GlobalParameters.LABEL_TEXT_SIZE_15_, VerticalOptions = LayoutOptions.Center }, p_list_zone_ } }, new Label(){ Text = "Periodo: ", FontSize = GlobalParameters.LABEL_TEXT_SIZE_15_, VerticalOptions = LayoutOptions.Center }, p_list_period_ } }, chart, new StackLayout () { Spacing = 20, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Horizontal, Children = { new StackLayout () { Spacing = 0, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.StartAndExpand, Orientation = StackOrientation.Vertical, Children = { new Label () { Text = "Exploratoria: ", FontAttributes = FontAttributes.Bold, FontSize = GlobalParameters.LABEL_TEXT_SIZE_15_, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Start, TextColor = GlobalParameters.COLORS_GRAPHIC01[0] }, labelExploratoria } }, new StackLayout () { Spacing = 0, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Vertical, Children = { new Label () { Text = "Temporada: ", FontAttributes = FontAttributes.Bold, FontSize = GlobalParameters.LABEL_TEXT_SIZE_15_, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Start, TextColor = GlobalParameters.COLORS_GRAPHIC01[1] }, labelTemporada } }, new StackLayout () { Spacing = 0, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.EndAndExpand, Orientation = StackOrientation.Vertical, Children = { new Label () { Text = "Saldo: ", FontAttributes = FontAttributes.Bold, FontSize = GlobalParameters.LABEL_TEXT_SIZE_15_, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.EndAndExpand, TextColor = GlobalParameters.COLORS_GRAPHIC01[2] }, labelSaldo } }, } } } }; main_page_ = main_layout; List<dtoAnio> yearNameList2 = await http_loader_.LoadAniosFromInternet (); p_list_year_.Items.Clear (); foreach (dtoAnio yearName in yearNameList2) { p_list_year_.Items.Add(yearName.anoTempo.ToString()); } p_list_year_.SelectedIndex = 0; chart.SelectionChanged += (object sender, ChartSelectionEventArgs csea) => { ShowGra02PescaRegionColumnWithData(); }; }
/// <summary> /// Initializes a new instance of the DoughnutSeriesAutomationPeer class. /// </summary> public DoughnutSeriesAutomationPeer(DoughnutSeries owner) : base(owner) { }
private void InitilizeChart() { SfChart chart = new SfChart(); ChartDataMarker chartDataMarker = new ChartDataMarker { LabelContent = LabelContent.Percentage, LabelStyle = new DataMarkerLabelStyle { BackgroundColor = Color.Transparent, Margin = new Thickness(5), TextColor = Color.FromHex("#B3B3B3"), LabelPosition = DataMarkerLabelPosition.Outer } }; DoughnutSeries doughnutSeries = new DoughnutSeries() { ItemsSource = _viewModel.ChartData, XBindingPath = "Name", YBindingPath = "Value", DoughnutCoefficient = 0.7, DataMarker = chartDataMarker, DataMarkerPosition = CircularSeriesDataMarkerPosition.Outside }; List <Color> colors = GetColorPalette(); doughnutSeries.ColorModel.Palette = ChartColorPalette.Custom; doughnutSeries.ColorModel.CustomBrushes = colors; chart.Series.Add(doughnutSeries); chart.HorizontalOptions = LayoutOptions.Center; chart.VerticalOptions = LayoutOptions.Center; ChartGrid.Children.Add(chart); StackLayout MiddleStack = new StackLayout() { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, BackgroundColor = Color.White, }; Label MiddleText0 = new Label() { Text = "100%", FontSize = 14, HorizontalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold, BackgroundColor = Color.White }; Label MiddleText1 = new Label() { Text = "2,468.40", FontSize = 25, HorizontalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }; Label MiddleText2 = new Label() { Text = "USD", FontSize = 14, HorizontalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }; MiddleStack.Children.Add(MiddleText0); MiddleStack.Children.Add(MiddleText1); MiddleStack.Children.Add(MiddleText2); // MiddleStack.BackgroundColor = Color.Transparent; ChartGrid.Children.Add(MiddleStack); }
public override View GetSampleContent(Context context) { var chart = new SfChart(context); chart.Title.Text = "Project Cost Breakdown"; chart.Title.TextSize = 15; chart.SetBackgroundColor(Color.White); chart.Legend.Visibility = Visibility.Visible; chart.Legend.DockPosition = ChartDock.Bottom; chart.Legend.ToggleSeriesVisibility = true; chart.Legend.OverflowMode = ChartLegendOverflowMode.Wrap; chart.Legend.IconHeight = 14; chart.Legend.IconWidth = 14; DoughnutSeries doughnutSeries = new DoughnutSeries(); doughnutSeries.DataPointSelectionEnabled = true; doughnutSeries.ColorModel.ColorPalette = ChartColorPalette.Natural; doughnutSeries.ExplodableOnTouch = true; doughnutSeries.ItemsSource = MainPage.GetDoughnutData(); doughnutSeries.XBindingPath = "XValue"; doughnutSeries.YBindingPath = "YValue"; doughnutSeries.DataMarker.ShowLabel = true; doughnutSeries.DataMarker.LabelStyle.LabelFormat = "#.##'M'"; doughnutSeries.EnableAnimation = true; chart.Series.Add(doughnutSeries); LinearLayout layout = new LinearLayout(context); layout.Orientation = Orientation.Vertical; TextView label = new TextView(context); label.Gravity = GravityFlags.Center; label.TextAlignment = Android.Views.TextAlignment.Center; label.Text = "Tap on slice"; TextView label1 = new TextView(context); label1.Gravity = GravityFlags.Center; label1.TextAlignment = Android.Views.TextAlignment.Center; layout.AddView(label); layout.AddView(label1); doughnutSeries.CenterView = layout; chart.SelectionChanging += (object sender, SfChart.SelectionChangingEventArgs e) => { if (doughnutSeries.ExplodeIndex >= 0) { var datapoints = e.P1.SelectedSeries.ItemsSource as List <DataPoint>; var datapoint = datapoints[e.P1.SelectedDataPointIndex].YValue; double total = 0; for (int i = 0; i < datapoints.Count; i++) { total = total + (double)datapoints[i].YValue; } double percentageValue = ((double)datapoint / total) * 100; string percentage = percentageValue.ToString("N2") + "%"; label.Text = percentage; var segments = e.P1.SelectedSeries.Segments; label.SetTextColor(segments[e.P1.SelectedDataPointIndex].Color); label1.Text = datapoints[e.P1.SelectedDataPointIndex].XValue.ToString(); label.TextSize = 19; doughnutSeries.CenterView = layout; e.P1.Cancel = true; } else { label1.Text = string.Empty; label.Text = "Tap on slice"; label.TextSize = 13; label.SetTextColor(label1.TextColors); doughnutSeries.CenterView = layout; e.P1.Cancel = true; } }; return(chart); }
private SfChart PrefChart(int type) { if (type == 1) { SfChart chart = new SfChart() { SideBySideSeriesPlacement = false, HeightRequest = 370, BackgroundColor = Color.Transparent }; Binding chartBind1 = new Binding("CatInfoSet"); chartBind1.Converter = new BarChartConverter(); chartBind1.ConverterParameter = 1; ColumnSeries series1 = new ColumnSeries(); series1.SetBinding(ChartSeries.ItemsSourceProperty, new Binding("CatInfoSet")); series1.XBindingPath = "Description"; series1.YBindingPath = "Weight"; series1.SetBinding(ColumnSeries.WidthProperty, chartBind1); series1.Color = Xamarin.Forms.Color.Transparent; series1.StrokeColor = Color.White; series1.CornerRadius = new ChartCornerRadius(10, 10, 0, 0); series1.StrokeWidth = 0.3; series1.EnableAnimation = false; series1.AnimationDuration = 0.8; series1.DataMarker = new ChartDataMarker(); DataTemplate dataMarkerTemplate2 = new DataTemplate(() => { StackLayout stack = new StackLayout() { Spacing = 0 }; stack.Orientation = StackOrientation.Horizontal; Label label1 = new Label() { TextColor = Color.White, FontSize = 12, VerticalOptions = LayoutOptions.Center }; label1.SetBinding(Label.TextProperty, "WeightPercent"); Label label2 = new Label() { TextColor = Color.White, FontSize = 12, VerticalOptions = LayoutOptions.Center }; label2.SetBinding(Label.TextProperty, "Weight", stringFormat: "/{0}"); stack.Children.Add(label1); stack.Children.Add(label2); return(stack); }); series1.DataMarker.LabelTemplate = dataMarkerTemplate2; Binding chartBind2 = new Binding("CatInfoSet"); chartBind2.Converter = new BarChartConverter(); chartBind2.ConverterParameter = 1; ColumnSeries series2 = new ColumnSeries(); series2.SetBinding(ChartSeries.ItemsSourceProperty, new Binding("CatInfoSet")); series2.XBindingPath = "Description"; series2.YBindingPath = "WeightPercent"; series2.SetBinding(ColumnSeries.WidthProperty, chartBind2); series2.Opacity = 1; Binding backCol = new Binding("CatInfoSet"); backCol.Converter = new BarChartConverter(); backCol.ConverterParameter = 4; series2.SetBinding(ChartSeries.ColorModelProperty, backCol); Binding labelOffsetBind = new Binding("CatInfoSet") { Converter = new BarChartConverter(), ConverterParameter = 2 }; series2.EnableAnimation = true; series2.CornerRadius = new ChartCornerRadius(10, 10, 0, 0); chart.Series.Add(series2); chart.Series.Add(series1); ChartZoomPanBehavior zoomPanBehavior = new ChartZoomPanBehavior(); chart.ChartBehaviors.Add(zoomPanBehavior); zoomPanBehavior.EnableDirectionalZooming = true; NumericalAxis numericalAxis = new NumericalAxis() { ShowMajorGridLines = true, ShowMinorGridLines = true, Minimum = 0, Maximum = 119, Name = "Score", Interval = 20, LabelStyle = new ChartAxisLabelStyle() { FontSize = 13, TextColor = Color.White, FontAttributes = FontAttributes.Bold } }; chart.SecondaryAxis = numericalAxis; chart.PrimaryAxis = new CategoryAxis() { Interval = 1, LabelPlacement = LabelPlacement.BetweenTicks, Name = "Prim" }; chart.PrimaryAxis.LabelStyle.FontAttributes = FontAttributes.Bold; chart.PrimaryAxis.LabelStyle.FontSize = 16; chart.SecondaryAxis.LabelStyle.FontSize = 12; chart.PrimaryAxis.LabelStyle.TextColor = Color.White; chart.PrimaryAxis.LabelsIntersectAction = AxisLabelsIntersectAction.MultipleRows; chart.PrimaryAxis.ShowMajorGridLines = false; chart.SecondaryAxis.ShowMajorGridLines = false; chart.SecondaryAxis.ShowMinorGridLines = false; return(chart); } else { SfChart chart = new SfChart() { HeightRequest = 230, BackgroundColor = Xamarin.Forms.Color.FromRgba(0, 0, 0, 0), HorizontalOptions = LayoutOptions.Start }; DoughnutSeries dSeries = new DoughnutSeries(); dSeries.SetBinding(ChartSeries.ItemsSourceProperty, new Binding("CatInfoSet")); dSeries.XBindingPath = "Description"; dSeries.YBindingPath = "Percent"; dSeries.IsStackedDoughnut = true; dSeries.Spacing = 0.6; Binding localBind = new Binding("CatInfoSet"); localBind.Converter = new ListViewConverterItem(); dSeries.SetBinding(DoughnutSeries.DoughnutCoefficientProperty, localBind); dSeries.MaximumValue = 100; dSeries.CapStyle = DoughnutCapStyle.BothCurve; dSeries.EnableAnimation = true; chart.Series.Add(dSeries); ChartLegend legend = new ChartLegend(); chart.Legend = legend; chart.Legend.DockPosition = LegendPlacement.Right; chart.Legend.Orientation = ChartOrientation.Vertical; chart.Legend.LabelStyle.TextColor = Color.White; legend.ItemTemplate = new DataTemplate(() => { StackLayout stack = new StackLayout() { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.EndAndExpand, Spacing = 5, VerticalOptions = LayoutOptions.StartAndExpand }; StackLayout SubStack = new StackLayout() { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.StartAndExpand, WidthRequest = 200, Spacing = 2 }; BoxView boxView = new BoxView() { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, WidthRequest = 15, HeightRequest = 15 }; boxView.SetBinding(BackgroundColorProperty, "IconColor"); Label name = new Label() { VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Start, HorizontalOptions = LayoutOptions.Center, FontSize = 13, TextColor = Color.White }; name.SetBinding(Label.TextProperty, "DataPoint.Description"); Frame frame = new Frame() { Padding = 1, Margin = 10, HeightRequest = 25, WidthRequest = 50, HorizontalOptions = LayoutOptions.EndAndExpand }; Label value = new Label() { HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, FontSize = 14, TextColor = Color.White, FontAttributes = FontAttributes.Bold, }; Binding TextBind = new Binding("DataPoint.Percent"); TextBind.Converter = new LegendItemConverter(); TextBind.StringFormat = "{0}%"; value.SetBinding(Label.TextProperty, TextBind); frame.Content = value; Binding colorBind = new Binding("DataPoint.Percent"); colorBind.Converter = new LegendItemConverter(); frame.SetBinding(BackgroundColorProperty, colorBind); SubStack.Children.Add(boxView); SubStack.Children.Add(name); SubStack.Children.Add(frame); stack.Children.Add(SubStack); return(stack); }); return(chart); } }
private void GetChart() { getData (); /* main_layout.Orientation = StackOrientation.Vertical; main_layout.Spacing = 15; main_layout.VerticalOptions = LayoutOptions.FillAndExpand; main_layout.HorizontalOptions = LayoutOptions.FillAndExpand; */ SfChart chart = new SfChart() { Legend = new ChartLegend(){ DockPosition = LegendPlacement.Bottom } }; ObservableCollection<ChartDataPoint> datas = new ObservableCollection<ChartDataPoint>(); datas.Add (new ChartDataPoint ("Exploratoria", 50)); datas.Add (new ChartDataPoint ("Temporada", 30)); datas.Add (new ChartDataPoint ("Saldo", 20)); //PieSeries DoughnutSeries pie = new DoughnutSeries(); //pie.ExplodeOnTouch = true; pie.ItemsSource = datas; pie.LegendIcon = ChartLegendIcon.Diamond; //pie.EnableDataPointSelection = true; //pie.DataMarker.ShowLabel = true; pie.DataMarkerPosition = CircularSeriesDataMarkerPosition.OutsideExtended; pie.ConnectorLineType = ConnectorLineType.Bezier; pie.DataMarker = new ChartDataMarker (); pie.DataMarker.ShowMarker = true; pie.DataMarker.MarkerWidth = 5; pie.DataMarker.LabelContent = LabelContent.Percentage; chart.Series.Add(pie); chart.VerticalOptions = LayoutOptions.FillAndExpand; chart.HorizontalOptions = LayoutOptions.FillAndExpand; ////////////// Picker# /// /// Picker Period p_list_period = new Picker { Title = "Periodo", VerticalOptions = LayoutOptions.StartAndExpand }; String [] periodNameList = {"periodo 1", "periodo 2"}; foreach (string periodName in periodNameList) { p_list_period.Items.Add(periodName); } p_list_period.SelectedIndex = 0; /// Picker year p_list_year = new Picker { Title = "Año", VerticalOptions = LayoutOptions.StartAndExpand }; String [] yearNameList = {"2010", "2011", "2012", "2013", "2014"}; foreach (string yearName in yearNameList) { p_list_year.Items.Add(yearName); } p_list_year.SelectedIndex = 0; /// Picker zona p_list_zone = new Picker { Title = "Zona", VerticalOptions = LayoutOptions.StartAndExpand }; String [] zoneNameList = {"Norte", "Sur", "Este", "Oeste"}; foreach (string zoneName in zoneNameList) { p_list_zone.Items.Add(zoneName); } p_list_zone.SelectedIndex = 0; p_list_year.SelectedIndexChanged += (sender, args) => { if (p_list_year.SelectedIndex == -1) { pie.ItemsSource = datas; } else { int num = p_list_year.SelectedIndex; ObservableCollection<ChartDataPoint> datas2 = new ObservableCollection<ChartDataPoint>(); datas2.Add (new ChartDataPoint ("Exploratoria", 50 * (num + 1) )); datas2.Add (new ChartDataPoint ("Temporada", 30)); datas2.Add (new ChartDataPoint ("Saldo", 20)); pie.ItemsSource = datas2; } }; pmenu_pesquera_ = GetMenuPesquera (); pmenu_pesquera_.VerticalOptions = LayoutOptions.Start; main_layout = new StackLayout (){ Padding = GlobalParameters.MAIN_LAYOUT_PADDING_, Spacing = 0, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Vertical, Children = { pmenu_pesquera_, new Label(){ Text = "AVANCE PESCA POR ZONA", HorizontalOptions = LayoutOptions.Center }, new StackLayout(){ Spacing = 0, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Children = { new Label(){ Text = "Año: ", FontSize = GlobalParameters.LABEL_TEXT_SIZE_15_ }, p_list_year, new StackLayout{ Spacing = 0, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Horizontal, Children = { new Label(){ Text = "Zona: ", FontSize = GlobalParameters.LABEL_TEXT_SIZE_15_ }, p_list_zone } }, new Label(){ Text = "Periodo: ", FontSize = GlobalParameters.LABEL_TEXT_SIZE_15_ }, p_list_period } }, chart } }; }
public DashboardPage() { InitializeComponent(); DashboardViewModel dvm = ((App)Application.Current).DashboardVM; BindingContext = dvm; //this.sli Photo1.Source = ImageSource.FromResource("Tulsi.Images.photo1.png"); Info1.Source = ImageSource.FromResource("Tulsi.Images.info.png"); User.Source = ImageSource.FromResource("Tulsi.Images.users.png"); Photo2.Source = ImageSource.FromResource("Tulsi.Images.photo1.png"); Info2.Source = ImageSource.FromResource("Tulsi.Images.info.png"); User2.Source = ImageSource.FromResource("Tulsi.Images.users.png"); Photo3.Source = ImageSource.FromResource("Tulsi.Images.photo1.png"); Info3.Source = ImageSource.FromResource("Tulsi.Images.info.png"); User3.Source = ImageSource.FromResource("Tulsi.Images.users.png"); //Slide menu creating SlideMenu = ((App)Application.Current).SideMenu; //Toolbar taps TapGestureRecognizer ToolbarTap1 = new TapGestureRecognizer(); ToolbarTap1.Tapped += (s, e) => { this.ShowMenu(); }; Menu.GestureRecognizers.Add(ToolbarTap1); TapGestureRecognizer ToolbarTap2 = new TapGestureRecognizer(); ToolbarTap2.Tapped += (s, e) => { SearchPage sp = new SearchPage(); Application.Current.MainPage.Navigation.PushAsync(sp); }; Search.GestureRecognizers.Add(ToolbarTap2); //In page navigation TapGestureRecognizer InPageNavigationTap1 = new TapGestureRecognizer(); InPageNavigationTap1.Tapped += (s, e) => { BuyerPage bp = new BuyerPage(); Application.Current.MainPage.Navigation.PushAsync(bp); }; ChartGrid.GestureRecognizers.Add(InPageNavigationTap1); TapGestureRecognizer InPageNavigationTap2 = new TapGestureRecognizer(); InPageNavigationTap2.Tapped += (s, e) => { TodayRatesPage trp = new TodayRatesPage(); Application.Current.MainPage.Navigation.PushAsync(trp); }; RatesGrid.GestureRecognizers.Add(InPageNavigationTap2); TapGestureRecognizer InPageNavigationTap3 = new TapGestureRecognizer(); InPageNavigationTap3.Tapped += (s, e) => { LadaanPage lp = new LadaanPage(); Application.Current.MainPage.Navigation.PushAsync(lp); }; ExtraRatesGrid.GestureRecognizers.Add(InPageNavigationTap3); TapGestureRecognizer InPageNavigationTap4 = new TapGestureRecognizer(); InPageNavigationTap4.Tapped += (s, e) => { NewsPage np = new NewsPage(); Application.Current.MainPage.Navigation.PushAsync(np); }; //News1.GestureRecognizers.Add(InPageNavigationTap4); //News2.GestureRecognizers.Add(InPageNavigationTap4); //News3.GestureRecognizers.Add(InPageNavigationTap4); SfChart chart = new SfChart(); DoughnutSeries doughnutSeries = new DoughnutSeries() { ItemsSource = dvm.ChartData, XBindingPath = "Name", YBindingPath = "Value", DoughnutCoefficient = 0.7, ExplodeIndex = 0 }; List <Color> colors = new List <Color>() { Color.FromHex("#82DA69"), Color.FromHex("#E47132"), Color.FromHex("#9EE5FC"), }; doughnutSeries.ColorModel.Palette = ChartColorPalette.Custom; doughnutSeries.ColorModel.CustomBrushes = colors; chart.WidthRequest = 180; chart.HeightRequest = 180; chart.Series.Add(doughnutSeries); chart.Title.TextColor = Color.FromHex("#cccccc"); chart.HorizontalOptions = LayoutOptions.Center; chart.VerticalOptions = LayoutOptions.Center; //chart.BackgroundColor = Color.FromHex("#F3F3F3"); chart.BackgroundColor = Color.Transparent; ChartGrid.Children.Add(chart); StackLayout MiddleStack = new StackLayout() { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, BackgroundColor = Color.White }; Label MiddleText1 = new Label() { Text = "23%", FontSize = 20, FontAttributes = FontAttributes.Bold }; Label MiddleText2 = new Label() { Text = "mobile", FontSize = 10, FontAttributes = FontAttributes.Bold }; MiddleStack.Children.Add(MiddleText1); MiddleStack.Children.Add(MiddleText2); ChartGrid.Children.Add(MiddleStack); /* * ListView NewsListView = new ListView(); * //NewsListView.BindingContext = dvm; * NewsListView.ItemsSource = dvm.NewsData; * NewsListView.ItemTemplate = new DataTemplate(() => { * Grid grid = new Grid * { * * RowDefinitions = * { * new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, * new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } * }, * ColumnDefinitions = * { * new ColumnDefinition { Width=new GridLength(2, GridUnitType.Star) }, * new ColumnDefinition { Width=new GridLength(5, GridUnitType.Star) }, * new ColumnDefinition { Width=new GridLength(2, GridUnitType.Star) }, * } * }; * * Label picture = new Label { HorizontalTextAlignment = TextAlignment.Center }; * //picture.SetBinding(Label.TextProperty, new Binding("Picture")); * picture.Text = "Picture"; * Label header = new Label { FontAttributes = FontAttributes.Bold, FontSize = 25 }; * //header.SetBinding(Label.TextProperty, new Binding("Header")); * header.Text = "Boating to the island"; * Label edited = new Label { FontSize = 15 }; * //edited.SetBinding(Label.TextProperty, new Binding("Edited")); * edited.Text = "Midified: date"; * Label icon = new Label { FontSize = 15, HorizontalTextAlignment = TextAlignment.Center }; * //icon.SetBinding(Label.TextProperty, new Binding("Icon")); * icon.Text = "icon"; * * grid.Children.Add(picture); * grid.Children.Add(header); * grid.Children.Add(edited); * grid.Children.Add(icon); * Grid.SetColumn(header, 1); * Grid.SetColumn(edited, 1); * Grid.SetColumn(icon, 2); * Grid.SetRow(edited, 1); * * return grid; * }); * MainLayout.Children.Add(NewsListView); */ }
private void OnChartTypeSelectionChanged1(object sender, SelectionChangedEventArgs e) { ComboBox comboBox = sender as ComboBox; if (comboBox.SelectedIndex == 0 && viewModel != null) { if (Accumulation_charts != null) { PieSeries series1 = new PieSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartLegend1.Visibility = Visibility.Visible; DataTemplate template1 = MainGrid.Resources["labelTemplate"] as DataTemplate; adornmentInfo1.ShowLabel = true; adornmentInfo1.LabelTemplate = template1; adornmentInfo1.AdornmentsPosition = AdornmentsPosition.Bottom; adornmentInfo1.HorizontalAlignment = HorizontalAlignment.Center; adornmentInfo1.VerticalAlignment = VerticalAlignment.Center; adornmentInfo1.ShowConnectorLine = true; adornmentInfo1.ConnectorHeight = 80; adornmentInfo1.ShowLabel = true; adornmentInfo1.UseSeriesPalette = true; adornmentInfo1.SegmentLabelContent = LabelContent.LabelContentPath; series1.XBindingPath = "Expense"; series1.YBindingPath = "Amount"; series1.ItemsSource = viewModel.Expenditure; series1.ConnectorType = ConnectorMode.Bezier; series1.PieCoefficient = 0.7; series1.EnableSmartLabels = true; series1.LabelPosition = CircularSeriesLabelPosition.OutsideExtended; series1.AdornmentsInfo = adornmentInfo1; Accumulation_charts.Header = "Agriculture Expenses Comparison"; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } } if (comboBox.SelectedIndex == 1 && viewModel != null) { PieSeries series1 = new PieSeries(); PieSeries series2 = new PieSeries(); PieSeries series3 = new PieSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartAdornmentInfo adornmentInfo2 = new ChartAdornmentInfo(); ChartAdornmentInfo adornmentInfo3 = new ChartAdornmentInfo(); ChartColorModel color1 = new ChartColorModel(); ChartColorModel color2 = new ChartColorModel(); ChartColorModel color3 = new ChartColorModel(); color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); DataTemplate template1 = MainGrid.Resources["populationLabelTemplate1"] as DataTemplate; DataTemplate template2 = MainGrid.Resources["populationLabelTemplate2"] as DataTemplate; DataTemplate template3 = MainGrid.Resources["populationLabelTemplate3"] as DataTemplate; ChartLegend1.Visibility = Visibility.Collapsed; adornmentInfo1.ShowLabel = true; adornmentInfo1.SegmentLabelContent = LabelContent.LabelContentPath; adornmentInfo1.LabelTemplate = template1; adornmentInfo2.ShowLabel = true; adornmentInfo2.SegmentLabelContent = LabelContent.LabelContentPath; adornmentInfo2.LabelTemplate = template2; adornmentInfo3.ShowLabel = true; adornmentInfo3.SegmentLabelContent = LabelContent.LabelContentPath; adornmentInfo3.LabelTemplate = template3; series1.ItemsSource = viewModel.Population; series1.XBindingPath = "Continent"; series1.YBindingPath = "PopulationinContinents"; series1.AdornmentsInfo = adornmentInfo1; series1.Stroke = new SolidColorBrush(Colors.White); series1.PieCoefficient = 1; series1.Label = "Continents"; series1.Palette = ChartColorPalette.Custom; series1.ColorModel = color1; series2.ItemsSource = viewModel.Population; series2.XBindingPath = "Countries"; series2.YBindingPath = "PopulationinCountries"; series2.AdornmentsInfo = adornmentInfo2; series2.Stroke = new SolidColorBrush(Colors.White); series2.PieCoefficient = 1; series2.Label = "Countries"; series2.Palette = ChartColorPalette.Custom; series2.ColorModel = color2; series3.ItemsSource = viewModel.Population; series3.XBindingPath = "States"; series3.YBindingPath = "PopulationinStates"; series3.AdornmentsInfo = adornmentInfo3; series3.Stroke = new SolidColorBrush(Colors.White); series3.PieCoefficient = 1; series3.Label = "States"; series3.Palette = ChartColorPalette.Custom; series3.ColorModel = color3; Accumulation_charts.Header = "Most populated continents"; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); Accumulation_charts.Series.Add(series2); Accumulation_charts.Series.Add(series3); } if (comboBox.SelectedIndex == 2 && viewModel != null) { PieSeries series1 = new PieSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartLegend1.Visibility = Visibility.Collapsed; series1.Margin = new Thickness(0, 25, 0, 0); adornmentInfo1.ShowLabel = true; adornmentInfo1.ShowConnectorLine = true; adornmentInfo1.UseSeriesPalette = true; adornmentInfo1.ConnectorHeight = 37; adornmentInfo1.SegmentLabelContent = LabelContent.Percentage; adornmentInfo1.SegmentLabelFormat = "##.#"; series1.XBindingPath = "Utilization"; series1.YBindingPath = "ResponseTime"; series1.StartAngle = 180; series1.EndAngle = 360; series1.ConnectorType = ConnectorMode.Bezier; series1.EnableSmartLabels = true; series1.LabelPosition = CircularSeriesLabelPosition.Outside; series1.ItemsSource = viewModel.Metric; series1.AdornmentsInfo = adornmentInfo1; Accumulation_charts.Header = "Application Performance Metrics"; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } if (comboBox.SelectedIndex == 3 && viewModel != null) { DoughnutSeries series1 = new DoughnutSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartLegend1.Visibility = Visibility.Visible; DataTemplate template1 = MainGrid.Resources["labeltemplate"] as DataTemplate; adornmentInfo1.ShowLabel = true; adornmentInfo1.LabelTemplate = template1; series1.XBindingPath = "CompanyName"; series1.YBindingPath = "CompanyTurnover"; series1.ItemsSource = viewModel.CompanyDetails; series1.AdornmentsInfo = adornmentInfo1; Accumulation_charts.Series.Clear(); Accumulation_charts.Header = "Top car company's turnover"; Accumulation_charts.Series.Add(series1); } if (comboBox.SelectedIndex == 4 && viewModel != null) { DoughnutSeries series1 = new DoughnutSeries(); DoughnutSeries series2 = new DoughnutSeries(); DoughnutSeries series3 = new DoughnutSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartAdornmentInfo adornmentInfo2 = new ChartAdornmentInfo(); ChartAdornmentInfo adornmentInfo3 = new ChartAdornmentInfo(); ChartColorModel color1 = new ChartColorModel(); ChartColorModel color2 = new ChartColorModel(); ChartColorModel color3 = new ChartColorModel(); color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color1.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color2.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 233, 70, 73))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 15, 185, 84))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); color3.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 82, 119))); DataTemplate template1 = MainGrid.Resources["populationLabelTemplate1"] as DataTemplate; DataTemplate template2 = MainGrid.Resources["populationLabelTemplate2"] as DataTemplate; DataTemplate template3 = MainGrid.Resources["populationLabelTemplate3"] as DataTemplate; ChartLegend1.Visibility = Visibility.Collapsed; adornmentInfo1.ShowLabel = true; adornmentInfo1.SegmentLabelContent = LabelContent.LabelContentPath; adornmentInfo1.LabelTemplate = template1; adornmentInfo2.ShowLabel = true; adornmentInfo2.SegmentLabelContent = LabelContent.LabelContentPath; adornmentInfo2.LabelTemplate = template2; adornmentInfo3.ShowLabel = true; adornmentInfo3.SegmentLabelContent = LabelContent.LabelContentPath; adornmentInfo3.LabelTemplate = template3; series1.ItemsSource = viewModel.Population; series1.XBindingPath = "Continent"; series1.YBindingPath = "PopulationinContinents"; series1.AdornmentsInfo = adornmentInfo1; series1.Stroke = new SolidColorBrush(Colors.White); series1.DoughnutCoefficient = 1; series1.DoughnutSize = 1; series1.Label = "Continents"; series1.Palette = ChartColorPalette.Custom; series1.ColorModel = color1; series2.ItemsSource = viewModel.Population; series2.XBindingPath = "Countries"; series2.YBindingPath = "PopulationinCountries"; series2.AdornmentsInfo = adornmentInfo2; series2.Stroke = new SolidColorBrush(Colors.White); series2.DoughnutCoefficient = 1; series2.DoughnutSize = 1; series2.Label = "Countries"; series2.Palette = ChartColorPalette.Custom; series2.ColorModel = color2; series3.ItemsSource = viewModel.Population; series3.XBindingPath = "States"; series3.YBindingPath = "PopulationinStates"; series3.AdornmentsInfo = adornmentInfo3; series3.Stroke = new SolidColorBrush(Colors.White); series3.DoughnutCoefficient = 1; series3.DoughnutSize = 1; series3.Label = "States"; series3.Palette = ChartColorPalette.Custom; series3.ColorModel = color3; Accumulation_charts.Header = "Most populated continents"; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); Accumulation_charts.Series.Add(series2); Accumulation_charts.Series.Add(series3); } if (comboBox.SelectedIndex == 5 && viewModel != null) { DoughnutSeries series1 = new DoughnutSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartLegend1.Visibility = Visibility.Collapsed; adornmentInfo1.ShowLabel = true; adornmentInfo1.ShowConnectorLine = true; adornmentInfo1.UseSeriesPalette = true; adornmentInfo1.ConnectorHeight = 37; adornmentInfo1.SegmentLabelContent = LabelContent.Percentage; adornmentInfo1.SegmentLabelFormat = "##.#"; series1.XBindingPath = "Utilization"; series1.YBindingPath = "ResponseTime"; series1.StartAngle = 180; series1.EndAngle = 360; series1.ConnectorType = ConnectorMode.Bezier; series1.EnableSmartLabels = true; series1.LabelPosition = CircularSeriesLabelPosition.Outside; series1.Margin = new Thickness(0, 25, 0, 0); series1.ItemsSource = viewModel.Metric; series1.AdornmentsInfo = adornmentInfo1; Accumulation_charts.Header = "Application Performance Metrics"; Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } if (comboBox.SelectedIndex == 6 && viewModel != null) { PyramidSeries series1 = new PyramidSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartLegend1.Visibility = Visibility.Collapsed; DataTemplate template1 = MainGrid.Resources["labelTemplate"] as DataTemplate; adornmentInfo1.ShowLabel = true; adornmentInfo1.LabelTemplate = template1; series1.XBindingPath = "CompanyName"; series1.YBindingPath = "CompanyTurnover"; series1.ItemsSource = viewModel.CompanyDetails; series1.AdornmentsInfo = adornmentInfo1; series1.Margin = new Thickness(20, 0, 20, 20); Accumulation_charts.Header = "Top car company's turnover"; Accumulation_charts.Margin = new Thickness(20, 20, 20, 20); Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } if (comboBox.SelectedIndex == 7 && viewModel != null) { FunnelSeries series1 = new FunnelSeries(); ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo(); ChartLegend1.Visibility = Visibility.Collapsed; DataTemplate template1 = MainGrid.Resources["labelTemplate"] as DataTemplate; adornmentInfo1.ShowLabel = true; adornmentInfo1.LabelTemplate = template1; series1.XBindingPath = "CompanyName"; series1.YBindingPath = "CompanyTurnover"; series1.ItemsSource = viewModel.CompanyDetails; series1.AdornmentsInfo = adornmentInfo1; series1.Margin = new Thickness(20, 0, 20, 20); Accumulation_charts.Header = "Top car company's turnover"; Accumulation_charts.Margin = new Thickness(20, 20, 20, 20); Accumulation_charts.Series.Clear(); Accumulation_charts.Series.Add(series1); } }
public override View GetSampleContent(Context context) { var chart = new SfChart(context);; chart.SetBackgroundColor(Color.White); chart.Legend.Visibility = Visibility.Visible; var datas = new ObservableArrayList(); datas.Add(new ChartDataPoint("2010", 8000)); datas.Add(new ChartDataPoint("2011", 8100)); datas.Add(new ChartDataPoint("2012", 8250)); datas.Add(new ChartDataPoint("2013", 8600)); datas.Add(new ChartDataPoint("2014", 8700)); var doughnutSeries = new DoughnutSeries { ExplodeIndex = 3, DataSource = datas, DataMarkerPosition = CircularSeriesDataMarkerPosition.OutsideExtended, }; doughnutSeries.DataMarker.ShowLabel = true; doughnutSeries.ConnectorType = ConnectorType.Bezier; chart.Series.Add(doughnutSeries); return chart; }