Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/07/17 16:55:03 (7 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/ScatterPlotContent.cs

    r14724 r14725  
    3030
    3131  public abstract class ScatterPlotContent : PreprocessingChartContent {
     32    public string GroupingVariable { get; set; }
     33
    3234    protected ScatterPlotContent(IFilteredPreprocessingData preprocessingData)
    3335      : base(preprocessingData) {
     
    3840    }
    3941
    40     public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY, string variableNameGroup = "-") {
     42    public static ScatterPlot CreateScatterPlot(IFilteredPreprocessingData preprocessingData, string variableNameX, string variableNameY, string variableNameGroup = "-") {
    4143      ScatterPlot scatterPlot = new ScatterPlot();
    4244
    43       IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX));
    44       IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY));
     45      IList<double> xValues = preprocessingData.GetValues<double>(preprocessingData.GetColumnIndex(variableNameX));
     46      IList<double> yValues = preprocessingData.GetValues<double>(preprocessingData.GetColumnIndex(variableNameY));
    4547
    4648      var points = xValues.Zip(yValues, (x, y) => new Point2D<double>(x, y)).ToList();
     
    7779
    7880      //Grouping
    79       int groupVariableIndex = PreprocessingData.GetColumnIndex(variableNameGroup);
     81      int groupVariableIndex = preprocessingData.GetColumnIndex(variableNameGroup);
    8082      var groupingValues = Enumerable.Empty<string>();
    8183
    82       if (PreprocessingData.VariableHasType<double>(groupVariableIndex)) {
    83         groupingValues = PreprocessingData.GetValues<double>(groupVariableIndex).Select(x => x.ToString());
    84       } else if (PreprocessingData.VariableHasType<string>(groupVariableIndex)) {
    85         groupingValues = PreprocessingData.GetValues<string>(groupVariableIndex);
    86       } else if (PreprocessingData.VariableHasType<DateTime>(groupVariableIndex)) {
    87         groupingValues = PreprocessingData.GetValues<DateTime>(groupVariableIndex).Select(x => x.ToString());
     84      if (preprocessingData.VariableHasType<double>(groupVariableIndex)) {
     85        groupingValues = preprocessingData.GetValues<double>(groupVariableIndex).Select(x => x.ToString());
     86      } else if (preprocessingData.VariableHasType<string>(groupVariableIndex)) {
     87        groupingValues = preprocessingData.GetValues<string>(groupVariableIndex);
     88      } else if (preprocessingData.VariableHasType<DateTime>(groupVariableIndex)) {
     89        groupingValues = preprocessingData.GetValues<DateTime>(groupVariableIndex).Select(x => x.ToString());
    8890      }
    8991      var groups = groupingValues.Zip(validPoints, Tuple.Create).GroupBy(t => t.Item1, t => t.Item2);
Note: See TracChangeset for help on using the changeset viewer.