Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/07/17 16:55:03 (8 years ago)
Author:
mkommend
Message:

#2709: Added grouping for multi scatter plot view.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/PreprocessingChartContent.cs

    r14581 r14725  
    6666
    6767    public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
    68       IList<double> values = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableName));
     68      return CreateDataRow(PreprocessingData, variableName, chartType);
     69    }
     70
     71    public static DataRow CreateDataRow(IFilteredPreprocessingData preprocessingData, string variableName, DataRowVisualProperties.DataRowChartType chartType) {
     72      IList<double> values = preprocessingData.GetValues<double>(preprocessingData.GetColumnIndex(variableName));
    6973      DataRow row = new DataRow(variableName, "", values);
    7074      row.VisualProperties.ChartType = chartType;
     
    8185      return new ReadOnlyCheckedItemList<StringValue>(itemList);
    8286    }
     87
     88    private const int MAX_DISTINCT_VALUES_FOR_GROUPING = 20;
     89    public static IEnumerable<string> GetVariableNamesForGrouping(IPreprocessingData preprocessingData) {
     90      var variableNames = new List<string>();
     91
     92      for (int i = 0; i < preprocessingData.Columns; ++i) {
     93        int distinctValues = Int32.MaxValue;
     94        if (preprocessingData.VariableHasType<double>(i))
     95          distinctValues = preprocessingData.GetValues<double>(i).GroupBy(x => x).Count();
     96        else if (preprocessingData.VariableHasType<string>(i))
     97          distinctValues = preprocessingData.GetValues<string>(i).GroupBy(x => x).Count();
     98        else if (preprocessingData.VariableHasType<DateTime>(i))
     99          distinctValues = preprocessingData.GetValues<DateTime>(i).GroupBy(x => x).Count();
     100
     101        if (distinctValues <= MAX_DISTINCT_VALUES_FOR_GROUPING)
     102          variableNames.Add(preprocessingData.GetVariableName(i));
     103      }
     104      return variableNames;
     105    }
    83106  }
    84107}
Note: See TracChangeset for help on using the changeset viewer.