Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/05/14 17:27:27 (11 years ago)
Author:
aesterer
Message:

Revised line chart and added histogram

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  
    2121
    2222
     23using System;
     24using System.Collections.Generic;
     25using HeuristicLab.Analysis;
     26
    2327namespace HeuristicLab.DataPreprocessing {
    2428  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    }
    25108  }
    26109}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/LineChartLogic.cs

    r10544 r10552  
    4848
    4949    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;
    5159    }
    5260
     
    5462      return dataTable;
    5563    }
    56 
    57 
    58     #region ILineChartLogic Members
    5964
    6065    public void RemoveVariable(string name) {
     
    6772      dataTable.Rows.Add(row);
    6873    }
    69 
    70     #endregion
    7174
    7275    public bool VariableIsDisplayed(string name) {
Note: See TracChangeset for help on using the changeset viewer.