Changeset 14993 for branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content
- Timestamp:
- 05/17/17 13:22:51 (8 years ago)
- Location:
- branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/HistogramContent.cs
r14725 r14993 39 39 public bool ExactBins { get; set; } 40 40 41 public LegendOrder Order { get; set; } 42 41 43 public HistogramContent(IFilteredPreprocessingData preprocessingData) 42 44 : base(preprocessingData) { … … 52 54 } 53 55 54 public static DataTable CreateHistogram(IFilteredPreprocessingData preprocessingData, string variableName, string groupingVariableName, DataRowVisualProperties.DataRowHistogramAggregation aggregation) { 55 { 56 var dataTable = new DataTable(); 56 public static DataTable CreateHistogram(IFilteredPreprocessingData preprocessingData, string variableName, string groupingVariableName, DataRowVisualProperties.DataRowHistogramAggregation aggregation, LegendOrder legendOrder = LegendOrder.Appearance) { 57 var dataTable = new DataTable(); 57 58 58 if (string.IsNullOrEmpty(groupingVariableName)) { 59 var row = PreprocessingChartContent.CreateDataRow(preprocessingData, variableName, DataRowVisualProperties.DataRowChartType.Histogram); 60 dataTable.Rows.Add(row); 61 return dataTable; 62 } 63 64 dataTable.VisualProperties.Title = variableName; 65 66 int variableIndex = preprocessingData.GetColumnIndex(variableName); 67 var variableValues = preprocessingData.GetValues<double>(variableIndex); 68 int groupVariableIndex = preprocessingData.GetColumnIndex(groupingVariableName); 69 var groupingValues = Enumerable.Empty<string>(); 70 71 if (preprocessingData.VariableHasType<double>(groupVariableIndex)) { 72 groupingValues = preprocessingData.GetValues<double>(groupVariableIndex).Select(x => x.ToString()); 73 } else if (preprocessingData.VariableHasType<string>(groupVariableIndex)) { 74 groupingValues = preprocessingData.GetValues<string>(groupVariableIndex); 75 } else if (preprocessingData.VariableHasType<DateTime>(groupVariableIndex)) { 76 groupingValues = preprocessingData.GetValues<DateTime>(groupVariableIndex).Select(x => x.ToString()); 77 } 78 79 var groups = groupingValues.Zip(variableValues, Tuple.Create).GroupBy(t => t.Item1, t => t.Item2); 80 81 foreach (var group in groups) { 82 var classRow = new DataRow(); 83 classRow.Name = group.Key; 84 classRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram; 85 classRow.VisualProperties.Aggregation = aggregation; 86 classRow.Values.AddRange(group); 87 dataTable.Rows.Add(classRow); 88 } 59 if (string.IsNullOrEmpty(groupingVariableName)) { 60 var row = PreprocessingChartContent.CreateDataRow(preprocessingData, variableName, DataRowVisualProperties.DataRowChartType.Histogram); 61 dataTable.Rows.Add(row); 89 62 return dataTable; 90 63 } 64 65 dataTable.VisualProperties.Title = variableName; 66 67 int variableIndex = preprocessingData.GetColumnIndex(variableName); 68 var variableValues = preprocessingData.GetValues<double>(variableIndex); 69 int groupVariableIndex = preprocessingData.GetColumnIndex(groupingVariableName); 70 var groupingValues = Enumerable.Empty<string>(); 71 72 if (preprocessingData.VariableHasType<double>(groupVariableIndex)) { 73 groupingValues = preprocessingData.GetValues<double>(groupVariableIndex).Select(x => x.ToString()); 74 } else if (preprocessingData.VariableHasType<string>(groupVariableIndex)) { 75 groupingValues = preprocessingData.GetValues<string>(groupVariableIndex); 76 } else if (preprocessingData.VariableHasType<DateTime>(groupVariableIndex)) { 77 groupingValues = preprocessingData.GetValues<DateTime>(groupVariableIndex).Select(x => x.ToString()); 78 } 79 80 var groups = groupingValues.Zip(variableValues, Tuple.Create).GroupBy(t => t.Item1, t => t.Item2); 81 82 if (legendOrder == LegendOrder.Alphabetically) 83 groups = groups.OrderBy(x => x.Key, new NaturalStringComparer()); 84 85 foreach (var group in groups) { 86 var classRow = new DataRow { 87 Name = group.Key, 88 VisualProperties = { 89 ChartType = DataRowVisualProperties.DataRowChartType.Histogram, 90 Aggregation = aggregation 91 } 92 }; 93 classRow.Values.AddRange(group); 94 dataTable.Rows.Add(classRow); 95 } 96 return dataTable; 91 97 } 92 93 94 98 } 95 99 } -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/PreprocessingChartContent.cs
r14725 r14993 33 33 [Item("PreprocessingChart", "Represents a preprocessing chart.")] 34 34 public class PreprocessingChartContent : Item, IViewShortcut { 35 36 public enum LegendOrder { 37 Appearance, 38 Alphabetically 39 } 40 35 41 public static new Image StaticItemImage { 36 42 get { return VSImageLibrary.PieChart; } -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/ScatterPlotContent.cs
r14725 r14993 40 40 } 41 41 42 public static ScatterPlot CreateScatterPlot(IFilteredPreprocessingData preprocessingData, string variableNameX, string variableNameY, string variableNameGroup = "-" ) {42 public static ScatterPlot CreateScatterPlot(IFilteredPreprocessingData preprocessingData, string variableNameX, string variableNameY, string variableNameGroup = "-", LegendOrder legendOrder = LegendOrder.Appearance) { 43 43 ScatterPlot scatterPlot = new ScatterPlot(); 44 44 … … 56 56 scatterPlot.VisualProperties.XAxisMinimumFixedValue = axisMin; 57 57 scatterPlot.VisualProperties.XAxisMaximumFixedValue = axisMax; 58 } 59 catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval 58 } catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval 60 59 try { 61 60 double axisMin, axisMax, axisInterval; … … 65 64 scatterPlot.VisualProperties.YAxisMinimumFixedValue = axisMin; 66 65 scatterPlot.VisualProperties.YAxisMaximumFixedValue = axisMax; 67 } 68 catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval 66 } catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval 69 67 } 70 68 … … 91 89 var groups = groupingValues.Zip(validPoints, Tuple.Create).GroupBy(t => t.Item1, t => t.Item2); 92 90 91 if (legendOrder == LegendOrder.Alphabetically) 92 groups = groups.OrderBy(x => x.Key, new NaturalStringComparer()); 93 93 94 foreach (var group in groups) { 94 var scdr = new ScatterPlotDataRow(); 95 scdr.Name = group.Key; 96 scdr.VisualProperties.IsVisibleInLegend = true; 97 scdr.VisualProperties.PointSize = 6; 95 var scdr = new ScatterPlotDataRow { 96 Name = group.Key, 97 VisualProperties = { 98 IsVisibleInLegend = true, 99 PointSize = 6 100 } 101 }; 98 102 scdr.Points.AddRange(group); 99 103 scatterPlot.Rows.Add(scdr);
Note: See TracChangeset
for help on using the changeset viewer.