protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Graph); string lip = Intent.GetStringExtra("DataFromOrder") ?? "Data not available"; int lateOrderY = Convert.ToInt16(NetHttp.FetchWaitAsync(App.Instance.GetUrl("lateOrderYear")).Result); int lateOrderM = Convert.ToInt16(NetHttp.FetchWaitAsync(App.Instance.GetUrl("lateOrderMonth")).Result); int lateOrderD = Convert.ToInt16(NetHttp.FetchWaitAsync(App.Instance.GetUrl("lateOrderToday")).Result); var data = new[] { lateOrderD, lateOrderM, lateOrderY }; var color = new Android.Graphics.Color[3] { Android.Graphics.Color.DarkGoldenrod, Android.Graphics.Color.Chocolate, Android.Graphics.Color.ForestGreen }; var leg = new[] { "Today", "Current Month", "Current Year" }; BarModel[] datab = new BarModel[3]; for (int i = 0; i < 3; i++) { datab[i] = new BarModel() { Value = data[i], Legend = leg[i], Color = color[i] }; } var chart = new BarChartView(this); chart = FindViewById <BarChart.BarChartView>(Resource.Id.barChart); chart.ItemsSource = datab; chart.Invalidate(); chart.BarWidth = 150; chart.LegendColor = Android.Graphics.Color.Black; chart.LegendFontSize = 24; }
private async void LoadData() { RunOnUiThread(() => { progressBar.Visibility = ViewStates.Visible; progressBar.Indeterminate = true; }); try { var items = await BarHelper.GenerateData(viewModel, Resources.GetColor(Resource.Color.bar_up), Resources.GetColor(Resource.Color.bar_down)); RunOnUiThread(() => { if (items.Count == 0) { MessageDialog.SendMessage(this, "There is no data for this group, please check in a few members first to a meetup.", "No Statistics"); return; } else if (viewModel.GroupsEventsCount.ContainsKey(0)) { MessageDialog.SendMessage(this, "Data for group needs synced, please re-visit all meetups to synchronize data and return for in depth statistics.", "No Statistics"); } barChart.ItemsSource = items; barChart.Invalidate(); }); } finally { RunOnUiThread(() => { progressBar.Visibility = ViewStates.Gone; progressBar.Indeterminate = false; }); } }