private void PieAllDonorHBCounts() { try { List <KeyValuePair <string, int> > list = new List <KeyValuePair <string, int> >(); var donations = balDonation.GetAll().GroupBy(donor => donor.HBCount).Select(group => new { Key = group.Key, Count = group.Count() }).OrderBy(x => x.Key); foreach (var item in donations) { list.Add(new KeyValuePair <string, int>(item.Key.ToString(), item.Count)); } List <string> colors = ColorShades.blueRedShades.ToList(); //colors.Reverse(); Charting.SetPieChart(pieChartAllDonorHBCounts, colors, list); } catch (Exception ex) { MessageHandler.ShowErrorMessage(ex.Message); } }
private void PieBloodByGroup() { try { List <KeyValuePair <string, int> > list = new List <KeyValuePair <string, int> >(); var inventories = balInventory.GetAll().Where(item => item.BloodBankID == MainWindow.CurrentAdminSystem.BloodBankID); var inventoryByGroup = inventories.GroupBy(inventory => inventory.BloodGroup).Select(group => new { Key = group.Key, Count = group.Sum(bottles => bottles.NumberofBottles) }).OrderBy(x => x.Key); foreach (var item in inventoryByGroup) { list.Add(new KeyValuePair <string, int>(item.Key, item.Count)); } List <string> colors = ColorShades.blueRedShades.ToList(); colors.Reverse(); Charting.SetPieChart(bloodByGroup, colors, list); } catch (Exception ex) { MessageHandler.ShowErrorMessage(ex.Message); } }