Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10913


Ignore:
Timestamp:
05/28/14 15:27:16 (10 years ago)
Author:
psteiner
Message:

DataCompletenessChart

Location:
branches/DataPreprocessing
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataCompletenessView.Designer.cs

    r10877 r10913  
    2525    /// </summary>
    2626    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();
    2833      this.SuspendLayout();
    2934      //
    30       // dataTableView1
     35      // chart
    3136      //
    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";
    3950      //
    4051      // DataCompletenessView
    4152      //
    42       this.Controls.Add(this.dataTableView1);
     53      this.Controls.Add(this.chart);
    4354      this.Name = "DataCompletenessView";
    4455      this.Size = new System.Drawing.Size(493, 344);
     56      ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
    4557      this.ResumeLayout(false);
    4658
     
    4961    #endregion
    5062
    51     private HeuristicLab.DataPreprocessing.Views.PreprocessingDataTableView dataTableView1;
     63    private Visualization.ChartControlsExtensions.EnhancedChart chart;
     64
    5265
    5366  }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataCompletenessView.cs

    r10877 r10913  
    44using HeuristicLab.MainForm;
    55using HeuristicLab.Core.Views;
     6using System.Collections.Generic;
     7using HeuristicLab.DataPreprocessing.Implementations;
     8using System.Drawing;
    69
    710namespace HeuristicLab.DataPreprocessing.Views {
     
    912  [View("Histogram View")]
    1013  [Content(typeof(DataCompletenessChartContent), true)]
    11   public partial class DataCompletenessView : ItemView {
     14  public partial class DataCompletenessView : ItemView
     15  {
    1216
    1317    protected DataRowVisualProperties.DataRowChartType chartType;
     
    1519
    1620    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>>();
    1724
    1825    public new DataCompletenessChartContent Content
     
    2633    {
    2734      InitializeComponent();
    28       chartType = DataRowVisualProperties.DataRowChartType.Line;
     35      chartType = DataRowVisualProperties.DataRowChartType.Bars;
    2936      chartTitle = DEFAULT_CHART_TITLE;
    3037    }
     
    3542      if (Content != null)
    3643      {
     44        InitData();
    3745      }
    3846    }
    3947
     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
    40166  }
    41167}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataPreprocessingView.cs

    r10908 r10913  
    6767          new HistogramContent(chartLogic),
    6868          new ScatterPlotContent(chartLogic),
    69           new CorrelationMatrixContent(problemData)
     69          new CorrelationMatrixContent(problemData),
     70          new DataCompletenessChartContent(dataGridLogic, searchLogic)
    7071        };
    7172
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataCompletenessChartContent.cs

    r10877 r10913  
    1212  public class DataCompletenessChartContent : Item, IViewShortcut
    1313  {
     14    private readonly DataGridLogic dataGridLogic;
     15    private readonly SearchLogic searchLogic;
    1416
    15     private readonly IChartLogic chartLogic;
    16 
    17     public DataCompletenessChartContent(IChartLogic chartLogic)
     17    public DataCompletenessChartContent(DataGridLogic dataGridLogic, SearchLogic searchLogic)
    1818    {
    19       this.chartLogic = chartLogic;
     19      this.dataGridLogic = dataGridLogic;
     20      this.searchLogic = searchLogic;
    2021    }
    2122
     
    2526    }
    2627
    27     public IChartLogic ChartLogic
     28    public IDataGridLogic DataGridLogic
    2829    {
    2930      get
    3031      {
    31         return chartLogic;
     32        return dataGridLogic;
     33      }
     34    }
     35
     36    public ISearchLogic SearchLogic
     37    {
     38      get
     39      {
     40        return searchLogic;
    3241      }
    3342    }
Note: See TracChangeset for help on using the changeset viewer.