Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14725


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

#2709: Added grouping for multi scatter plot view.

Location:
branches/DataPreprocessing Enhancements
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs

    r14583 r14725  
    2121
    2222using System;
    23 using System.Linq;
    2423using HeuristicLab.Analysis;
    2524using HeuristicLab.MainForm;
     
    4645
    4746      if (Content != null) {
    48         foreach (string var in GetVariableNamesForGrouping(Content.PreprocessingData)) {
     47        foreach (string var in PreprocessingChartContent.GetVariableNamesForGrouping(Content.PreprocessingData)) {
    4948          classifierComboBox.Items.Add(var);
    5049        }
     
    5554
    5655    protected override DataTable CreateDataTable(string variableName) {
    57       var dataTable = new DataTable();
    58 
    59       if (string.IsNullOrEmpty(Content.GroupingVariableName)) {
    60         var row = Content.CreateDataRow(variableName, DataRowVisualProperties.DataRowChartType.Histogram);
    61         dataTable.Rows.Add(row);
    62         return dataTable;
    63       }
    64 
    65       dataTable.VisualProperties.Title = variableName;
    66 
    67       int variableIndex = Content.PreprocessingData.GetColumnIndex(variableName);
    68       var variableValues = Content.PreprocessingData.GetValues<double>(variableIndex);
    69       int groupVariableIndex = Content.PreprocessingData.GetColumnIndex(Content.GroupingVariableName);
    70       var groupingValues = Enumerable.Empty<string>();
    71 
    72       if (Content.PreprocessingData.VariableHasType<double>(groupVariableIndex)) {
    73         groupingValues = Content.PreprocessingData.GetValues<double>(groupVariableIndex).Select(x => x.ToString());
    74       } else if (Content.PreprocessingData.VariableHasType<string>(groupVariableIndex)) {
    75         groupingValues = Content.PreprocessingData.GetValues<string>(groupVariableIndex);
    76       } else if (Content.PreprocessingData.VariableHasType<DateTime>(groupVariableIndex)) {
    77         groupingValues = Content.PreprocessingData.GetValues<DateTime>(groupVariableIndex).Select(x => x.ToString());
    78       }
    79 
    80       var groups = groupingValues.Zip(variableValues, Tuple.Create).GroupBy(t => t.Item1, t => t.Item2);
    81 
    82       foreach (var group in groups) {
    83         var classRow = new DataRow();
    84         classRow.Name = group.Key;
    85         classRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
    86         classRow.VisualProperties.Aggregation = (DataRowVisualProperties.DataRowHistogramAggregation)aggregationComboBox.SelectedItem;
    87         classRow.Values.AddRange(group);
    88         dataTable.Rows.Add(classRow);
    89       }
    90       return dataTable;
     56      var aggregation = (DataRowVisualProperties.DataRowHistogramAggregation)aggregationComboBox.SelectedItem;
     57      return HistogramContent.CreateHistogram(Content.PreprocessingData, variableName, Content.GroupingVariableName, aggregation);
    9158    }
    92 
    9359
    9460    private void classifierComboBox_SelectedIndexChanged(object sender, EventArgs e) {
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.cs

    r14581 r14725  
    3535  [View("Preprocessing Chart View")]
    3636  [Content(typeof(PreprocessingChartContent), false)]
    37   public partial class PreprocessingChartView : PreprocessingCheckedVariablesView {
    38     private const int MAX_DISTINCT_VALUES_FOR_GROUPING = 20;
     37  public partial class PreprocessingChartView : PreprocessingCheckedVariablesView { 
    3938    protected Dictionary<string, DataTable> dataTables;
    4039    protected Dictionary<string, DataTableControl> dataTableControls;
     
    6463        GenerateLayout();
    6564      }
    66     }
    67 
    68     protected static IEnumerable<string> GetVariableNamesForGrouping(IPreprocessingData preprocessingData) {
    69       var variableNames = new List<string>();
    70 
    71       for (int i = 0; i < preprocessingData.Columns; ++i) {
    72         int distinctValues = Int32.MaxValue;
    73         if (preprocessingData.VariableHasType<double>(i))
    74           distinctValues = preprocessingData.GetValues<double>(i).GroupBy(x => x).Count();
    75         else if (preprocessingData.VariableHasType<string>(i))
    76           distinctValues = preprocessingData.GetValues<string>(i).GroupBy(x => x).Count();
    77         else if (preprocessingData.VariableHasType<DateTime>(i))
    78           distinctValues = preprocessingData.GetValues<DateTime>(i).GroupBy(x => x).Count();
    79 
    80         if (distinctValues <= MAX_DISTINCT_VALUES_FOR_GROUPING)
    81           variableNames.Add(preprocessingData.GetVariableName(i));
    82       }
    83       return variableNames;
    8465    }
    8566
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.Designer.cs

    r14514 r14725  
    6262      this.orderLabel = new System.Windows.Forms.Label();
    6363      this.label4 = new System.Windows.Forms.Label();
     64      this.groupingOptionsBox = new System.Windows.Forms.GroupBox();
     65      this.groupingComboBox = new System.Windows.Forms.ComboBox();
    6466      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    6567      this.splitContainer.Panel1.SuspendLayout();
     
    7577      this.regressionGroupBox.SuspendLayout();
    7678      ((System.ComponentModel.ISupportInitialize)(this.polynomialRegressionOrderNumericUpDown)).BeginInit();
     79      this.groupingOptionsBox.SuspendLayout();
    7780      this.SuspendLayout();
    7881      //
     
    8386      //
    8487      this.splitContainer.Panel1.Controls.Add(this.sizeGroupBox);
     88      this.splitContainer.Panel1.Controls.Add(this.groupingOptionsBox);
    8589      this.splitContainer.Panel1.Controls.Add(this.regressionGroupBox);
    8690      //
     
    195199      this.sizeGroupBox.Controls.Add(this.widthTrackBar);
    196200      this.sizeGroupBox.Dock = System.Windows.Forms.DockStyle.Bottom;
    197       this.sizeGroupBox.Location = new System.Drawing.Point(0, 198);
     201      this.sizeGroupBox.Location = new System.Drawing.Point(0, 154);
    198202      this.sizeGroupBox.Name = "sizeGroupBox";
    199203      this.sizeGroupBox.Size = new System.Drawing.Size(180, 130);
     
    319323      this.label4.TabIndex = 13;
    320324      this.label4.Text = "Type:";
     325      //
     326      // groupingOptionsBox
     327      //
     328      this.groupingOptionsBox.Controls.Add(this.groupingComboBox);
     329      this.groupingOptionsBox.Dock = System.Windows.Forms.DockStyle.Bottom;
     330      this.groupingOptionsBox.Location = new System.Drawing.Point(0, 284);
     331      this.groupingOptionsBox.Name = "groupingOptionsBox";
     332      this.groupingOptionsBox.Size = new System.Drawing.Size(180, 44);
     333      this.groupingOptionsBox.TabIndex = 8;
     334      this.groupingOptionsBox.TabStop = false;
     335      this.groupingOptionsBox.Text = "Grouping Variable";
     336      //
     337      // groupingComboBox
     338      //
     339      this.groupingComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     340            | System.Windows.Forms.AnchorStyles.Right)));
     341      this.groupingComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     342      this.groupingComboBox.FormattingEnabled = true;
     343      this.groupingComboBox.Location = new System.Drawing.Point(6, 19);
     344      this.groupingComboBox.Name = "groupingComboBox";
     345      this.groupingComboBox.Size = new System.Drawing.Size(169, 21);
     346      this.groupingComboBox.TabIndex = 1;
     347      this.groupingComboBox.SelectedIndexChanged += new System.EventHandler(this.groupingComboBox_SelectedIndexChanged);
    321348      //
    322349      // ScatterPlotMultiView
     
    343370      this.regressionGroupBox.PerformLayout();
    344371      ((System.ComponentModel.ISupportInitialize)(this.polynomialRegressionOrderNumericUpDown)).EndInit();
     372      this.groupingOptionsBox.ResumeLayout(false);
    345373      this.ResumeLayout(false);
    346374
     
    366394    private System.Windows.Forms.Label orderLabel;
    367395    private System.Windows.Forms.Label label4;
     396    private System.Windows.Forms.GroupBox groupingOptionsBox;
     397    private System.Windows.Forms.ComboBox groupingComboBox;
    368398  }
    369399}
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.cs

    r14580 r14725  
    5555      base.OnContentChanged();
    5656      if (Content != null) {
     57        groupingComboBox.Items.Add("");
     58        foreach (string var in PreprocessingChartContent.GetVariableNamesForGrouping(Content.PreprocessingData)) {
     59          groupingComboBox.Items.Add(var);
     60        }
     61        groupingComboBox.SelectedItem = Content.GroupingVariable;
     62
    5763        GenerateCharts();
    5864      }
     
    261267      if (!bodyCache.ContainsKey(key)) {
    262268        if (rowVariable == colVariable) { // use historgram if x and y variable are equal
    263           var dataTable = new DataTable();
    264           DataRow dataRow = Content.CreateDataRow(rowVariable, DataRowVisualProperties.DataRowChartType.Histogram);
    265           dataRow.VisualProperties.IsVisibleInLegend = false;
    266           dataTable.Rows.Add(dataRow);
     269          var dataTable = HistogramContent.CreateHistogram(Content.PreprocessingData, rowVariable, (string)groupingComboBox.SelectedItem, DataRowVisualProperties.DataRowHistogramAggregation.Overlapping);
     270          foreach (var dataRow in dataTable.Rows)
     271            dataRow.VisualProperties.IsVisibleInLegend = false;
     272
    267273          var pcv = new DataTableControl {
    268274            Name = key.ToString(),
     
    275281          bodyCache.Add(key, pcv);
    276282        } else { //scatter plot
    277           var scatterPlot = Content.CreateScatterPlot(colVariable, rowVariable);
     283          var scatterPlot = ScatterPlotContent.CreateScatterPlot(Content.PreprocessingData, colVariable, rowVariable, (string)groupingComboBox.SelectedItem);
    278284          var regressionType = (RegressionType)regressionTypeComboBox.SelectedValue;
    279285          int order = (int)polynomialRegressionOrderNumericUpDown.Value;
     
    486492    }
    487493    #endregion
     494
     495    private void groupingComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     496      GenerateCharts();
     497    }
    488498  }
    489499}
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotSingleView.Designer.cs

    r14724 r14725  
    144144      // comboBoxGroup
    145145      //
    146       this.comboBoxGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     146      this.comboBoxGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    147147            | System.Windows.Forms.AnchorStyles.Right)));
    148148      this.comboBoxGroup.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
     
    159159      // comboBoxYVariable
    160160      //
    161       this.comboBoxYVariable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     161      this.comboBoxYVariable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    162162            | System.Windows.Forms.AnchorStyles.Right)));
    163163      this.comboBoxYVariable.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
     
    173173      // comboBoxXVariable
    174174      //
    175       this.comboBoxXVariable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     175      this.comboBoxXVariable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    176176            | System.Windows.Forms.AnchorStyles.Right)));
    177177      this.comboBoxXVariable.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
     
    201201      // regressionTypeComboBox
    202202      //
    203       this.regressionTypeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     203      this.regressionTypeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    204204            | System.Windows.Forms.AnchorStyles.Right)));
    205205      this.regressionTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     
    213213      // polynomialRegressionOrderNumericUpDown
    214214      //
    215       this.polynomialRegressionOrderNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     215      this.polynomialRegressionOrderNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    216216            | System.Windows.Forms.AnchorStyles.Right)));
    217217      this.polynomialRegressionOrderNumericUpDown.Location = new System.Drawing.Point(51, 47);
     
    288288      // gradientPictureBox
    289289      //
    290       this.gradientPictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     290      this.gradientPictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    291291            | System.Windows.Forms.AnchorStyles.Left)));
    292292      this.gradientPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     
    363363    private System.Windows.Forms.Label gradientMinimumLabel;
    364364    private System.Windows.Forms.Label gradientMaximumLabel;
    365     protected System.Windows.Forms.PictureBox gradientPictureBox;
     365    private System.Windows.Forms.PictureBox gradientPictureBox;
    366366  }
    367367}
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotSingleView.cs

    r14724 r14725  
    3636  [Content(typeof(SingleScatterPlotContent), true)]
    3737  public sealed partial class ScatterPlotSingleView : ItemView {
    38     private const int MAX_DISTINCT_VALUES_FOR_GROUPING = 20;
    3938    private readonly string NoGroupItem = "";
    4039
     
    7473      comboBoxYVariable.Items.AddRange(variables.ToArray());
    7574      comboBoxGroup.Items.Add(NoGroupItem);
    76       foreach (string var in GetVariableNamesForGrouping(Content.PreprocessingData)) {
     75      foreach (string var in PreprocessingChartContent.GetVariableNamesForGrouping(Content.PreprocessingData)) {
    7776        comboBoxGroup.Items.Add(var);
    7877      }
    79       comboBoxGroup.SelectedItem = Content.SelectedGroupVariable;
     78      comboBoxGroup.SelectedItem = Content.GroupingVariable;
    8079
    8180      // use x and y variable from content
    82       if (Content.SelectedXVariable != null && Content.SelectedYVariable != null && Content.SelectedGroupVariable != null) {
     81      if (Content.SelectedXVariable != null && Content.SelectedYVariable != null && Content.GroupingVariable != null) {
    8382        comboBoxXVariable.SelectedItem = Content.SelectedXVariable;
    8483        comboBoxYVariable.SelectedItem = Content.SelectedYVariable;
    85         comboBoxGroup.SelectedItem = Content.SelectedGroupVariable;
     84        comboBoxGroup.SelectedItem = Content.GroupingVariable;
    8685      } else {
    8786        if (variables.Count() >= 2) {
     
    10099        var groupVariable = (string)comboBoxGroup.SelectedItem;
    101100
    102         ScatterPlot scatterPlot = Content.CreateScatterPlot(xVariable, yVariable, groupVariable);
     101        ScatterPlot scatterPlot = ScatterPlotContent.CreateScatterPlot(Content.PreprocessingData, xVariable, yVariable, groupVariable);
    103102        //rows are saved and removed to avoid firing of visual property changed events
    104103        var rows = scatterPlot.Rows.ToList();
     
    124123        this.Content.SelectedXVariable = (string)comboBoxXVariable.SelectedItem;
    125124        this.Content.SelectedYVariable = (string)comboBoxYVariable.SelectedItem;
    126         this.Content.SelectedGroupVariable = (string)comboBoxGroup.SelectedItem;
     125        this.Content.GroupingVariable = (string)comboBoxGroup.SelectedItem;
    127126      }
    128127    }
     
    241240      return colors[index];
    242241    }
    243 
    244     private static IEnumerable<string> GetVariableNamesForGrouping(IPreprocessingData preprocessingData) {
    245       var variableNames = new List<string>();
    246 
    247       for (int i = 0; i < preprocessingData.Columns; ++i) {
    248         int distinctValues = Int32.MaxValue;
    249         if (preprocessingData.VariableHasType<double>(i))
    250           distinctValues = preprocessingData.GetValues<double>(i).GroupBy(x => x).Count();
    251         else if (preprocessingData.VariableHasType<string>(i))
    252           distinctValues = preprocessingData.GetValues<string>(i).GroupBy(x => x).Count();
    253         else if (preprocessingData.VariableHasType<DateTime>(i))
    254           distinctValues = preprocessingData.GetValues<DateTime>(i).GroupBy(x => x).Count();
    255 
    256         if (distinctValues <= MAX_DISTINCT_VALUES_FOR_GROUPING)
    257           variableNames.Add(preprocessingData.GetVariableName(i));
    258       }
    259       return variableNames;
    260     }
    261242  }
    262243}
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/HistogramContent.cs

    r14581 r14725  
    2020#endregion
    2121
     22using System;
    2223using System.Drawing;
     24using System.Linq;
     25using HeuristicLab.Analysis;
    2326using HeuristicLab.Common;
    2427using HeuristicLab.Core;
     
    4952    }
    5053
     54    public static DataTable CreateHistogram(IFilteredPreprocessingData preprocessingData, string variableName, string groupingVariableName, DataRowVisualProperties.DataRowHistogramAggregation aggregation) {
     55      {
     56        var dataTable = new DataTable();
     57
     58        if (string.IsNullOrEmpty(groupingVariableName)) {
     59          var row = PreprocessingChartContent.CreateDataRow(preprocessingData, variableName, DataRowVisualProperties.DataRowChartType.Histogram);
     60          dataTable.Rows.Add(row);
     61          return dataTable;
     62        }
     63
     64        dataTable.VisualProperties.Title = variableName;
     65
     66        int variableIndex = preprocessingData.GetColumnIndex(variableName);
     67        var variableValues = preprocessingData.GetValues<double>(variableIndex);
     68        int groupVariableIndex = preprocessingData.GetColumnIndex(groupingVariableName);
     69        var groupingValues = Enumerable.Empty<string>();
     70
     71        if (preprocessingData.VariableHasType<double>(groupVariableIndex)) {
     72          groupingValues = preprocessingData.GetValues<double>(groupVariableIndex).Select(x => x.ToString());
     73        } else if (preprocessingData.VariableHasType<string>(groupVariableIndex)) {
     74          groupingValues = preprocessingData.GetValues<string>(groupVariableIndex);
     75        } else if (preprocessingData.VariableHasType<DateTime>(groupVariableIndex)) {
     76          groupingValues = preprocessingData.GetValues<DateTime>(groupVariableIndex).Select(x => x.ToString());
     77        }
     78
     79        var groups = groupingValues.Zip(variableValues, Tuple.Create).GroupBy(t => t.Item1, t => t.Item2);
     80
     81        foreach (var group in groups) {
     82          var classRow = new DataRow();
     83          classRow.Name = group.Key;
     84          classRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
     85          classRow.VisualProperties.Aggregation = aggregation;
     86          classRow.Values.AddRange(group);
     87          dataTable.Rows.Add(classRow);
     88        }
     89        return dataTable;
     90      }
     91    }
     92
    5193
    5294  }
  • 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}
  • 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);
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/SingleScatterPlotContent.cs

    r14467 r14725  
    3131    public string SelectedXVariable { get; set; }
    3232    public string SelectedYVariable { get; set; }
    33     public string SelectedGroupVariable { get; set; }
    3433
    3534    public SingleScatterPlotContent(IFilteredPreprocessingData preprocessingData)
     
    4140      this.SelectedXVariable = content.SelectedXVariable;
    4241      this.SelectedYVariable = content.SelectedYVariable;
    43       this.SelectedGroupVariable = content.SelectedGroupVariable;
     42      this.GroupingVariable = content.GroupingVariable;
    4443    }
    4544
Note: See TracChangeset for help on using the changeset viewer.