- Timestamp:
- 03/05/14 17:27:27 (11 years ago)
- Location:
- branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/HistogramLogic.cs
r10539 r10552 21 21 22 22 23 using System; 24 using System.Collections.Generic; 25 using HeuristicLab.Analysis; 26 23 27 namespace HeuristicLab.DataPreprocessing { 24 28 public class HistogramLogic : IHistogramLogic { 29 private IPreprocessingData preprocessingData; 30 private DataTable dataTable; 31 32 public HistogramLogic(IPreprocessingData preprocessingData) { 33 this.preprocessingData = preprocessingData; 34 dataTable = new DataTable("Histogram"); 35 FillDataTable(); 36 preprocessingData.Changed += PreprocessingData_Changed; 37 } 38 39 private void FillDataTable() { 40 IEnumerable<string> variableNames = preprocessingData.VariableNames; 41 42 foreach (string variableName in variableNames) { 43 IList<double> values = preprocessingData.GetValues<double>(variableName); 44 DataRow row = new DataRow(variableName, "", values); 45 row.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram; 46 dataTable.Rows.Add(row); 47 } 48 49 } 50 51 public IEnumerable<object> GetVariableNames() { 52 List<string> doubleVariableNames = new List<string>(); 53 54 //only return variable names from type double 55 foreach (string variableName in preprocessingData.VariableNames) { 56 if (preprocessingData.IsType<double>(preprocessingData.GetColumnIndex(variableName))) 57 doubleVariableNames.Add(variableName); 58 } 59 60 return doubleVariableNames; 61 } 62 63 public DataTable GetDataTable() { 64 return dataTable; 65 } 66 67 public void RemoveVariable(string name) { 68 dataTable.Rows.Remove(name); 69 } 70 71 public void AddVariable(string name) { 72 IList<double> values = preprocessingData.GetValues<double>(name); 73 DataRow row = new DataRow(name, "", values); 74 row.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram; 75 dataTable.Rows.Add(row); 76 } 77 78 public bool VariableIsDisplayed(string name) { 79 80 foreach (var item in dataTable.Rows) { 81 if (item.Name == name) 82 return true; 83 } 84 return false; 85 } 86 87 void PreprocessingData_Changed(object sender, DataPreprocessingChangedEventArgs e) { 88 var variableName = preprocessingData.GetVariableName(e.Column); 89 switch (e.Type) { 90 case DataPreprocessingChangedEventType.DeleteColumn: 91 dataTable.Rows.Remove(variableName); 92 break; 93 case DataPreprocessingChangedEventType.AddColumn: 94 dataTable.Rows.Add(new DataRow(variableName, String.Empty, preprocessingData.GetValues<double>(e.Column))); 95 break; 96 case DataPreprocessingChangedEventType.ChangeColumn: 97 case DataPreprocessingChangedEventType.ChangeItem: 98 dataTable.Rows.Remove(variableName); 99 dataTable.Rows.Add(new DataRow(variableName, String.Empty, preprocessingData.GetValues<double>(e.Column))); 100 break; 101 case DataPreprocessingChangedEventType.DeleteRow: 102 case DataPreprocessingChangedEventType.AddRow: 103 dataTable.Rows.Clear(); 104 FillDataTable(); 105 break; 106 } 107 } 25 108 } 26 109 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/LineChartLogic.cs
r10544 r10552 48 48 49 49 public IEnumerable<object> GetVariableNames() { 50 return preprocessingData.VariableNames; 50 List<string> doubleVariableNames = new List<string>(); 51 52 //only return variable names from type double 53 foreach (string variableName in preprocessingData.VariableNames) { 54 if (preprocessingData.IsType<double>(preprocessingData.GetColumnIndex(variableName))) 55 doubleVariableNames.Add(variableName); 56 } 57 58 return doubleVariableNames; 51 59 } 52 60 … … 54 62 return dataTable; 55 63 } 56 57 58 #region ILineChartLogic Members59 64 60 65 public void RemoveVariable(string name) { … … 67 72 dataTable.Rows.Add(row); 68 73 } 69 70 #endregion71 74 72 75 public bool VariableIsDisplayed(string name) {
Note: See TracChangeset
for help on using the changeset viewer.