Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static PieChart GetPieChart(IEnumerable<AFBaseElement> myElements, string key, List<string> attributeNames, bool flag)
- {
- if (flag)
- {
- List<string> afList = new List<string>();
- foreach (string temp in attributeNames)
- {
- var attributeValues = GetValuesFromElements(myElements, temp);
- var filteredAttributeValues = attributeValues.Where(v => v.IsGood).Select(v => ConvertToDouble(v)).ToList();
- var output = filteredAttributeValues.Sum().ToString();
- afList.Add(output);
- }
- PieChart newPieChart = new PieChart(afList, attributeNames, key);
- return newPieChart;
- }
- else
- {
- List<string> afList = new List<string>();
- var attributeNameToValue = new Dictionary<string, double>();
- foreach (string temp in attributeNames)
- {
- var attributeValues = GetValuesFromElements(myElements, temp);
- var filteredAttributeValues = attributeValues.Where(v => v.IsGood).Select(v => ConvertToDouble(v)).ToList();
- var output = filteredAttributeValues.Sum();
- attributeNameToValue.Add(temp, output);
- }
- var result = attributeNameToValue.OrderByDescending(val => val.Value);
- List<string> orderedList = new List<string>();
- int count = 0;
- foreach(var kvp in result)
- {
- if(count < 10)
- {
- afList.Add(kvp.Value.ToString());
- orderedList.Add(kvp.Key);
- count++;
- }
- }
- PieChart newPieChart = new PieChart(afList, orderedList, key);
- return newPieChart;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement