- Timestamp:
- 07/14/16 22:38:23 (8 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 13502,13504,13507-13508,13512,13514,13517
- Property svn:mergeinfo changed
-
stable/HeuristicLab.DataPreprocessing.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.DataPreprocessing.Views merged: 13502,13504,13507-13508,13512,13514,13517
- Property svn:mergeinfo changed
-
stable/HeuristicLab.DataPreprocessing.Views/3.4/DataCompletenessView.cs
r11002 r14075 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 23 using System.Collections.Generic; 24 using System.Drawing; 2 25 using System.Windows.Forms; 3 using HeuristicLab.Analysis; 26 using System.Windows.Forms.DataVisualization.Charting; 27 using HeuristicLab.Core.Views; 4 28 using HeuristicLab.MainForm; 5 using HeuristicLab.Core.Views;6 using System.Collections.Generic;7 using HeuristicLab.DataPreprocessing.Implementations;8 using System.Drawing;9 using System.Windows.Forms.DataVisualization.Charting;10 29 11 30 namespace HeuristicLab.DataPreprocessing.Views { … … 13 32 [View("Histogram View")] 14 33 [Content(typeof(DataCompletenessChartContent), true)] 15 public partial class DataCompletenessView : ItemView 16 { 34 public partial class DataCompletenessView : ItemView { 17 35 18 36 //list of columns, bool indicates wether the cell is a missing value or not … … 22 40 private static Color colorMissingVal = Color.Orange; 23 41 24 public new DataCompletenessChartContent Content 25 { 42 public new DataCompletenessChartContent Content { 26 43 get { return (DataCompletenessChartContent)base.Content; } 27 44 set { base.Content = value; } … … 29 46 30 47 31 public DataCompletenessView() 32 { 48 public DataCompletenessView() { 33 49 InitializeComponent(); 34 50 } 35 51 36 protected override void OnContentChanged() 37 { 52 protected override void OnContentChanged() { 38 53 base.OnContentChanged(); 39 if (Content != null) 40 { 54 if (Content != null) { 41 55 InitData(); 42 56 } 43 57 } 44 58 45 private void InitData() 46 { 59 private void InitData() { 47 60 IDictionary<int, IList<int>> missingValueIndices = Content.SearchLogic.GetMissingValueIndices(); 48 for (int i = 0; i < Content.SearchLogic.Columns; i++) 49 { 61 for (int i = 0; i < Content.SearchLogic.Columns; i++) { 50 62 //append column 51 63 List<bool> column = new List<bool>(); … … 60 72 } 61 73 62 private void PrepareChart() 63 { 74 private void PrepareChart() { 64 75 chart.Titles.Add("DataCompletenessChart"); 65 76 chart.EnableDoubleClickResetsZoom = true; … … 74 85 //custom x axis label 75 86 double from = 0.5; 76 foreach (String columnName in Content.SearchLogic.VariableNames) 77 { 87 foreach (String columnName in Content.SearchLogic.VariableNames) { 78 88 double to = from + 1; 79 89 chart.ChartAreas[0].AxisX.CustomLabels.Add(from, to, columnName); … … 84 94 } 85 95 86 private void CreateSeries(List<List<int>> yValuesPerColumn) 87 { 96 private void CreateSeries(List<List<int>> yValuesPerColumn) { 88 97 //prepare series 89 98 int seriesCount = DetermineSeriesCount(yValuesPerColumn); 90 for (int i = 0; i < seriesCount; i++) 91 { 99 for (int i = 0; i < seriesCount; i++) { 92 100 chart.Series.Add(CreateSeriesName(i)); 93 101 Series series = chart.Series[CreateSeriesName(i)]; … … 95 103 series.IsVisibleInLegend = false; 96 104 series["PointWidth"] = "1.0"; 97 if (i % 2 == 0) 98 { 105 if (i % 2 == 0) { 99 106 if (i == 0) //show legend for non missing values only once 100 107 series.IsVisibleInLegend = true; 101 108 series.Color = colorNonMissingVal; 102 } 103 else 104 { 109 } else { 105 110 if (i == 1) //show legend for missing values only once 106 111 series.IsVisibleInLegend = true; … … 109 114 } 110 115 //fill series 111 for (int i = 0; i < yValuesPerColumn.Count; i++) 112 { 116 for (int i = 0; i < yValuesPerColumn.Count; i++) { 113 117 List<int> column = yValuesPerColumn[i]; 114 118 for (int j = 0; j < seriesCount; j++) { … … 122 126 } 123 127 124 private String CreateSeriesName(int index) 125 { 128 private String CreateSeriesName(int index) { 126 129 if (index == 0) 127 130 return "non-missing value"; … … 132 135 133 136 #region data_preparation_for_chartseries 134 private int DetermineSeriesCount(List<List<int>> yValuesPerColumn) 135 { 137 private int DetermineSeriesCount(List<List<int>> yValuesPerColumn) { 136 138 int highest = 0; 137 139 foreach (List<int> values in yValuesPerColumn) { … … 141 143 } 142 144 143 private List<List<int>> ProcessMatrixForCharting(List<List<bool>> matrix, IDictionary<int, IList<int>> missingValueIndices) 144 { 145 private List<List<int>> ProcessMatrixForCharting(List<List<bool>> matrix, IDictionary<int, IList<int>> missingValueIndices) { 145 146 List<List<int>> columnsYValues = new List<List<int>>(); 146 for (int i =0; i < matrix.Count; i++) //column147 for (int i = 0; i < matrix.Count; i++) //column 147 148 { 148 149 List<int> yValues = new List<int>(); … … 150 151 bool missingState = false; 151 152 int valueCount = 0; 152 for (int j = 0; j < column.Count; j++ ) { 153 if (missingState == missingValueIndices[i].Contains(j)) 154 { 153 for (int j = 0; j < column.Count; j++) { 154 if (missingState == missingValueIndices[i].Contains(j)) { 155 155 valueCount++; 156 } 157 else 158 { 156 } else { 159 157 yValues.Add(valueCount); 160 158 valueCount = 1;
Note: See TracChangeset
for help on using the changeset viewer.