async Task Chart1Calcul(List <SkiaSharp.SKColor> colorTab) { //--------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------chart Interest By residence - Chart1---------------------------------------- var residenceInterest = await StoreManager.ContactCustomFieldSourceEntryStore.GetItemsByContactCustomFieldSourceName("Résidences"); if (residenceInterest != null && residenceInterest.Any()) { Chart1Visible = true; var entries1 = new List <Microcharts.Entry>(); var i = 0; foreach (var itemRes in residenceInterest) { var contactInterested = await StoreManager.ContactCustomFieldStore.GetTotalCountByContactCustomFieldSourceEntryId(itemRes.Id, dateDeb, dateFin); entries1.Add( new Microcharts.Entry(contactInterested) { Label = itemRes.Value, ValueLabel = contactInterested.ToString(), // Color = new SkiaSharp.SKColor(108, 8, 23), Color = colorTab[i] }); i++; } var listt = (entries1.OrderByDescending(x => x.Value)).ToList(); var listEntries = new List <Microcharts.Entry>(); // calcul limite boucle (max 5 elements) int limitFor; if (listt.Count < 5) { limitFor = listt.Count; } else { limitFor = 5; } for (var r = 0; r < limitFor; r++) { listEntries.Add(listt[r]); } Chart1 = new Microcharts.BarChart { Entries = listEntries }; } }
private async void LoadDatosVentas() { try { var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { await Application.Current.MainPage.DisplayAlert( "Error", connection.Message, "Aceptar" ); return; } var response = await apiService.GetList <VentasDia>("http://181.48.119.100:3058", "/api", "/ventasdia"); if (!response.IsSuccess) { await Application.Current.MainPage.DisplayAlert( "Error", response.Message, "Aceptar" ); return; } var list = (List <VentasDia>)response.Result; this.ventasDia = new ObservableCollection <VentasDia>(list); this.Valor001 = float.Parse(VentasDia.Where(p => p.CO == "001").Select(r => r.Valor).FirstOrDefault().ToString()) / 1000; this.Valor002 = float.Parse(VentasDia.Where(p => p.CO == "002").Select(r => r.Valor).FirstOrDefault().ToString()) / 1000; this.Valor003 = float.Parse(VentasDia.Where(p => p.CO == "003").Select(r => r.Valor).FirstOrDefault().ToString()) / 1000; this.Valor004 = float.Parse(VentasDia.Where(p => p.CO == "004").Select(r => r.Valor).FirstOrDefault().ToString()) / 1000; this.Valor008 = float.Parse(VentasDia.Where(p => p.CO == "008").Select(r => r.Valor).FirstOrDefault().ToString()) / 1000; this.Valor009 = float.Parse(VentasDia.Where(p => p.CO == "009").Select(r => r.Valor).FirstOrDefault().ToString()) / 1000; this.Valor019 = float.Parse(VentasDia.Where(p => p.CO == "019").Select(r => r.Valor).FirstOrDefault().ToString()) / 1000; this.Valor025 = float.Parse(VentasDia.Where(p => p.CO == "025").Select(r => r.Valor).FirstOrDefault().ToString()) / 1000; List <datachar> datacharlist = new List <datachar>() { new datachar(Valor001) { Color = NavyColor, TextColor = NavyColor, Label = "NACIONAL", ValueLabel = Valor001.ToString(), }, new datachar(Valor002) { Color = AccentColor, TextColor = AccentColor, Label = "CCA", ValueLabel = Valor002.ToString(), }, new datachar(Valor003) { Color = VerdeColor, TextColor = VerdeColor, Label = "CMED", ValueLabel = Valor003.ToString(), }, new datachar(Valor004) { Color = GreenColor, TextColor = GreenColor, Label = "OU70", ValueLabel = Valor004.ToString(), }, new datachar(Valor008) { Color = PinkColor, TextColor = PinkColor, Label = "CBQUILLA", ValueLabel = Valor008.ToString(), }, new datachar(Valor009) { Color = OrangeColor, TextColor = OrangeColor, Label = "REMATE", ValueLabel = Valor009.ToString(), }, new datachar(Valor019) { Color = AzulColor, TextColor = AzulColor, Label = "INSTITUCIONAL", ValueLabel = Valor019.ToString(), }, new datachar(Valor025) { Color = FucsiaColor, TextColor = FucsiaColor, Label = "SALOMIA", ValueLabel = Valor025.ToString(), }, }; GraficoVentas = new Microcharts.BarChart() { Entries = datacharlist, }; } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert( "Error", ex.Message, "Aceptar" ); } }