- Timestamp:
- 12/20/16 15:28:14 (8 years ago)
- Location:
- branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/PreprocessingChartContent.cs
r14467 r14511 36 36 private ICheckedItemList<StringValue> variableItemList = null; 37 37 public ICheckedItemList<StringValue> VariableItemList { 38 get { return this.variableItemList; } 39 set { this.variableItemList = value; } 38 get { 39 if (variableItemList == null) 40 variableItemList = CreateVariableItemList(); 41 return this.variableItemList; 42 } 43 //set { this.variableItemList = value; } 40 44 } 41 45 … … 65 69 66 70 67 public ICheckedItemList<StringValue> CreateVariableItemList(IList<string> checkedItems = null) { 68 if (checkedItems == null) checkedItems = new string[0]; 71 public ICheckedItemList<StringValue> CreateVariableItemList() { 69 72 ICheckedItemList<StringValue> itemList = new CheckedItemList<StringValue>(); 70 73 foreach (string name in PreprocessingData.GetDoubleVariableNames()) { 71 74 var n = new StringValue(name); 72 itemList.Add(n, checkedItems.Contains(name)); 75 bool isInputTarget = PreprocessingData.InputVariables.Contains(name) || PreprocessingData.TargetVariable == name; 76 itemList.Add(n, isInputTarget); 73 77 } 74 78 return new ReadOnlyCheckedItemList<StringValue>(itemList); -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/ScatterPlotContent.cs
r14495 r14511 42 42 ScatterPlot scatterPlot = new ScatterPlot(); 43 43 44 IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX)) .Where(x => !double.IsNaN(x) && !double.IsInfinity(x)).ToList();45 IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY)) .Where(x => !double.IsNaN(x) && !double.IsInfinity(x)).ToList();44 IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX)); 45 IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY)); 46 46 47 if (xValues.Any()) { 47 var points = xValues.Zip(yValues, (x, y) => new Point2D<double>(x, y)).ToList(); 48 var validPoints = points.Where(p => !double.IsNaN(p.X) && !double.IsNaN(p.Y) && !double.IsInfinity(p.X) && !double.IsInfinity(p.Y)).ToList(); 49 if (validPoints.Any()) { 48 50 try { 49 51 double axisMin, axisMax, axisInterval; 50 ChartUtil.CalculateOptimalAxisInterval( xValues.Min(), xValues.Max(), out axisMin, out axisMax, out axisInterval);52 ChartUtil.CalculateOptimalAxisInterval(validPoints.Min(p => p.X), validPoints.Max(p => p.X), out axisMin, out axisMax, out axisInterval); 51 53 scatterPlot.VisualProperties.XAxisMinimumAuto = false; 52 54 scatterPlot.VisualProperties.XAxisMaximumAuto = false; … … 54 56 scatterPlot.VisualProperties.XAxisMaximumFixedValue = axisMax; 55 57 } catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval 56 }57 if (yValues.Any()) {58 58 try { 59 59 double axisMin, axisMax, axisInterval; 60 ChartUtil.CalculateOptimalAxisInterval( yValues.Min(), yValues.Max(), out axisMin, out axisMax, out axisInterval);60 ChartUtil.CalculateOptimalAxisInterval(validPoints.Min(p => p.Y), validPoints.Max(p => p.Y), out axisMin, out axisMax, out axisInterval); 61 61 scatterPlot.VisualProperties.YAxisMinimumAuto = false; 62 62 scatterPlot.VisualProperties.YAxisMaximumAuto = false; … … 67 67 68 68 if (variableNameGroup == null || variableNameGroup == "-") { 69 List<Point2D<double>> points = new List<Point2D<double>>(); 70 71 for (int i = 0; i < xValues.Count; i++) { 72 Point2D<double> point = new Point2D<double>(xValues[i], yValues[i]); 73 points.Add(point); 74 } 75 76 ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points); 69 ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", validPoints); 77 70 scdr.VisualProperties.IsVisibleInLegend = false; 78 71 scatterPlot.Rows.Add(scdr); 79 80 72 } else { 81 73 var groupValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameGroup)); 82 var data = xValues.Zip(yValues, (x, y) => new { x, y }).Zip(groupValues, (v, c) => new { v.x, v.y, c }).ToList();74 var data = points.Zip(groupValues, (p, g) => new { p, g }); 83 75 foreach (var groupValue in groupValues.Distinct()) { 84 var values = data.Where(x => x.c == groupValue); 85 var row = new ScatterPlotDataRow( 86 variableNameGroup + " (" + groupValue + ")", 87 "", 88 values.Select(v => new Point2D<double>(v.x, v.y))) { 76 var values = data.Where(x => x.g == groupValue).Select(v => v.p); 77 var row = new ScatterPlotDataRow(string.Format("{0} ({1})", variableNameGroup, groupValue), "", values) { 89 78 VisualProperties = { PointSize = 6 } 90 79 };
Note: See TracChangeset
for help on using the changeset viewer.