Changeset 10913
- Timestamp:
- 05/28/14 15:27:16 (11 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataCompletenessView.Designer.cs
r10877 r10913 25 25 /// </summary> 26 26 private void InitializeComponent() { 27 this.dataTableView1 = new DataPreprocessing.Views.PreprocessingDataTableView(); 27 this.components = new System.ComponentModel.Container(); 28 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); 29 System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); 30 System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series(); 31 this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart(); 32 ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit(); 28 33 this.SuspendLayout(); 29 34 // 30 // dataTableView135 // chart 31 36 // 32 this.dataTableView1.Caption = "DataTable View"; 33 this.dataTableView1.Content = null; 34 this.dataTableView1.Location = new System.Drawing.Point(60, 36); 35 this.dataTableView1.Name = "dataTableView1"; 36 this.dataTableView1.ReadOnly = false; 37 this.dataTableView1.Size = new System.Drawing.Size(359, 274); 38 this.dataTableView1.TabIndex = 0; 37 chartArea1.Name = "ChartArea1"; 38 this.chart.ChartAreas.Add(chartArea1); 39 legend1.Name = "Legend1"; 40 this.chart.Legends.Add(legend1); 41 this.chart.Location = new System.Drawing.Point(4, 4); 42 this.chart.Name = "chart"; 43 series1.ChartArea = "ChartArea1"; 44 series1.Legend = "Legend1"; 45 series1.Name = "Series1"; 46 this.chart.Series.Add(series1); 47 this.chart.Size = new System.Drawing.Size(486, 337); 48 this.chart.TabIndex = 0; 49 this.chart.Text = "enhancedChart1"; 39 50 // 40 51 // DataCompletenessView 41 52 // 42 this.Controls.Add(this. dataTableView1);53 this.Controls.Add(this.chart); 43 54 this.Name = "DataCompletenessView"; 44 55 this.Size = new System.Drawing.Size(493, 344); 56 ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit(); 45 57 this.ResumeLayout(false); 46 58 … … 49 61 #endregion 50 62 51 private HeuristicLab.DataPreprocessing.Views.PreprocessingDataTableView dataTableView1; 63 private Visualization.ChartControlsExtensions.EnhancedChart chart; 64 52 65 53 66 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataCompletenessView.cs
r10877 r10913 4 4 using HeuristicLab.MainForm; 5 5 using HeuristicLab.Core.Views; 6 using System.Collections.Generic; 7 using HeuristicLab.DataPreprocessing.Implementations; 8 using System.Drawing; 6 9 7 10 namespace HeuristicLab.DataPreprocessing.Views { … … 9 12 [View("Histogram View")] 10 13 [Content(typeof(DataCompletenessChartContent), true)] 11 public partial class DataCompletenessView : ItemView { 14 public partial class DataCompletenessView : ItemView 15 { 12 16 13 17 protected DataRowVisualProperties.DataRowChartType chartType; … … 15 19 16 20 private const string DEFAULT_CHART_TITLE = "DataCompletenessChart"; 21 22 //list of columns, bool indicates wether the cell is a missing value or not 23 private List<List<bool>> matrix = new List<List<bool>>(); 17 24 18 25 public new DataCompletenessChartContent Content … … 26 33 { 27 34 InitializeComponent(); 28 chartType = DataRowVisualProperties.DataRowChartType. Line;35 chartType = DataRowVisualProperties.DataRowChartType.Bars; 29 36 chartTitle = DEFAULT_CHART_TITLE; 30 37 } … … 35 42 if (Content != null) 36 43 { 44 InitData(); 37 45 } 38 46 } 39 47 48 private void InitData() 49 { 50 IDictionary<int, IList<int>> missingValueIndices = Content.SearchLogic.GetMissingValueIndices(); 51 for (int i = 0; i < Content.DataGridLogic.Columns; i++) 52 { 53 //append column 54 List<bool> column = new List<bool>(); 55 for (int j=0; j < Content.DataGridLogic.Rows; j++) { 56 column.Add(missingValueIndices[i].Contains(j)); 57 } 58 matrix.Add(column); 59 } 60 List<List<int>> yValuesPerColumn = ProcessMatrixForCharting(matrix, missingValueIndices); 61 createSeries(yValuesPerColumn); 62 //CreateChart(); 63 } 64 65 private void createSeries(List<List<int>> yValuesPerColumn) 66 { 67 //prepare series 68 int seriesCount = determineSeriesCount(yValuesPerColumn); 69 for (int i = 0; i < seriesCount; i++) 70 { 71 chart.Series.Add("series"+i); 72 chart.Series["series"+i].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedColumn; 73 if (i % 2 == 0) 74 chart.Series["series" + i].Color = Color.Blue; 75 else 76 chart.Series["series" + i].Color = Color.White; 77 } 78 //fill series 79 for (int i = 0; i < yValuesPerColumn.Count; i++) 80 { 81 List<int> column = yValuesPerColumn[i]; 82 for (int j = 0; j < seriesCount; j++) { 83 if (column.Count - 1 < j) { 84 chart.Series["series"+j].Points.AddY(0); 85 } else { 86 chart.Series["series" + j].Points.AddY(column[j]); 87 } 88 } 89 } 90 } 91 92 private int determineSeriesCount(List<List<int>> yValuesPerColumn) 93 { 94 int highest = 0; 95 foreach (List<int> values in yValuesPerColumn) { 96 highest = Math.Max(values.Count, highest); 97 } 98 return highest; 99 } 100 101 private List<List<int>> ProcessMatrixForCharting(List<List<bool>> matrix, IDictionary<int, IList<int>> missingValueIndices) 102 { 103 List<List<int>> columnsYValues = new List<List<int>>(); 104 for (int i=0; i < matrix.Count; i++) //column 105 { 106 List<int> yValues = new List<int>(); 107 List<bool> column = matrix[i]; 108 bool missingState = false; 109 int valueCount = 0; 110 for (int j = 0; j < column.Count; j++ ) { 111 if (missingState == missingValueIndices[i].Contains(j)) 112 { 113 valueCount++; 114 } 115 else 116 { 117 yValues.Add(valueCount); 118 valueCount = 1; 119 missingState = !missingState; 120 } 121 } 122 yValues.Add(valueCount); 123 /* 124 List<int> yValues = new List<int>(); 125 bool missingChanged = true; 126 while () 127 * */ 128 columnsYValues.Add(yValues); 129 } 130 return columnsYValues; 131 } 132 133 const String missingValue = "Red"; 134 const String existingValue = "DarkBlue"; 135 136 137 private void CreateChart() 138 { 139 object[] temp = new[] { "1", "50" }; 140 object[] temp2 = new[] { "50", "1000" }; 141 chart.Series.Add(missingValue); 142 chart.Series.Add(existingValue); 143 144 for(int i=0; i < matrix.Count; i++) { 145 List<bool> column = matrix[i]; 146 for (int j = 0; j < column.Count; j++ ) 147 { 148 chart.Series[missingValue].Points.AddXY(i, temp); 149 chart.Series[existingValue].Points.AddXY(i, temp2); 150 chart.Series[missingValue].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedBar; 151 chart.Series[existingValue].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedBar; 152 } 153 } 154 } 155 156 /* 157 private DataRow columnToDataRow(List<bool> column, int i) 158 { 159 DataRow row = new DataRow("row"+i); 160 foreach (bool missing in column) { 161 row.Values.Add(missing? 1 : 0); 162 } 163 return row; 164 }*/ 165 40 166 } 41 167 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataPreprocessingView.cs
r10908 r10913 67 67 new HistogramContent(chartLogic), 68 68 new ScatterPlotContent(chartLogic), 69 new CorrelationMatrixContent(problemData) 69 new CorrelationMatrixContent(problemData), 70 new DataCompletenessChartContent(dataGridLogic, searchLogic) 70 71 }; 71 72 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataCompletenessChartContent.cs
r10877 r10913 12 12 public class DataCompletenessChartContent : Item, IViewShortcut 13 13 { 14 private readonly DataGridLogic dataGridLogic; 15 private readonly SearchLogic searchLogic; 14 16 15 private readonly IChartLogic chartLogic; 16 17 public DataCompletenessChartContent(IChartLogic chartLogic) 17 public DataCompletenessChartContent(DataGridLogic dataGridLogic, SearchLogic searchLogic) 18 18 { 19 this.chartLogic = chartLogic; 19 this.dataGridLogic = dataGridLogic; 20 this.searchLogic = searchLogic; 20 21 } 21 22 … … 25 26 } 26 27 27 public I ChartLogic ChartLogic28 public IDataGridLogic DataGridLogic 28 29 { 29 30 get 30 31 { 31 return chartLogic; 32 return dataGridLogic; 33 } 34 } 35 36 public ISearchLogic SearchLogic 37 { 38 get 39 { 40 return searchLogic; 32 41 } 33 42 }
Note: See TracChangeset
for help on using the changeset viewer.