Index: /branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotSingleView.Designer.cs
===================================================================
--- /branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotSingleView.Designer.cs	(revision 14723)
+++ /branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotSingleView.Designer.cs	(revision 14724)
@@ -144,8 +144,9 @@
       // comboBoxGroup
       // 
-      this.comboBoxGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+      this.comboBoxGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
       this.comboBoxGroup.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
       this.comboBoxGroup.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
+      this.comboBoxGroup.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
       this.comboBoxGroup.FormattingEnabled = true;
       this.comboBoxGroup.Location = new System.Drawing.Point(51, 94);
@@ -158,5 +159,5 @@
       // comboBoxYVariable
       // 
-      this.comboBoxYVariable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+      this.comboBoxYVariable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
       this.comboBoxYVariable.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
@@ -172,5 +173,5 @@
       // comboBoxXVariable
       // 
-      this.comboBoxXVariable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+      this.comboBoxXVariable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
       this.comboBoxXVariable.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
@@ -200,5 +201,5 @@
       // regressionTypeComboBox
       // 
-      this.regressionTypeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+      this.regressionTypeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
       this.regressionTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
@@ -212,5 +213,5 @@
       // polynomialRegressionOrderNumericUpDown
       // 
-      this.polynomialRegressionOrderNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+      this.polynomialRegressionOrderNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
       this.polynomialRegressionOrderNumericUpDown.Location = new System.Drawing.Point(51, 47);
@@ -287,5 +288,5 @@
       // gradientPictureBox
       // 
-      this.gradientPictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+      this.gradientPictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
             | System.Windows.Forms.AnchorStyles.Left)));
       this.gradientPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
Index: /branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotSingleView.cs
===================================================================
--- /branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotSingleView.cs	(revision 14723)
+++ /branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotSingleView.cs	(revision 14724)
@@ -35,7 +35,7 @@
   [View("Scatter Plot Single View")]
   [Content(typeof(SingleScatterPlotContent), true)]
-  public partial class ScatterPlotSingleView : ItemView {
-
-    private readonly string NoGroupItem = "-";
+  public sealed partial class ScatterPlotSingleView : ItemView {
+    private const int MAX_DISTINCT_VALUES_FOR_GROUPING = 20;
+    private readonly string NoGroupItem = "";
 
     public new SingleScatterPlotContent Content {
@@ -51,21 +51,31 @@
     }
 
-    public void InitData() {
+    protected override void SetEnabledStateOfControls() {
+      base.SetEnabledStateOfControls();
+      useGradientCheckBox.Enabled = (string)comboBoxGroup.SelectedItem != NoGroupItem;
+      gradientPanel.Visible = useGradientCheckBox.Enabled && useGradientCheckBox.Checked; ;
+    }
+
+    protected override void OnContentChanged() {
+      base.OnContentChanged();
+      if (Content != null) {
+        InitData();
+      }
+    }
+
+    private void InitData() {
       IEnumerable<string> variables = Content.PreprocessingData.GetDoubleVariableNames();
 
-      // add variables to combo boxes
       comboBoxXVariable.Items.Clear();
       comboBoxYVariable.Items.Clear();
       comboBoxGroup.Items.Clear();
+
       comboBoxXVariable.Items.AddRange(variables.ToArray());
       comboBoxYVariable.Items.AddRange(variables.ToArray());
       comboBoxGroup.Items.Add(NoGroupItem);
-      for (int i = 0; i < Content.PreprocessingData.Columns; ++i) {
-        if (Content.PreprocessingData.VariableHasType<double>(i)) {
-          //double distinctValueCount = Content.PreprocessingData.GetValues<double>(i).GroupBy(x => x).Count();
-          //if (distinctValueCount <= 20)
-          comboBoxGroup.Items.Add(Content.PreprocessingData.GetVariableName(i));
-        }
-      }
+      foreach (string var in GetVariableNamesForGrouping(Content.PreprocessingData)) {
+        comboBoxGroup.Items.Add(var);
+      }
+      comboBoxGroup.SelectedItem = Content.SelectedGroupVariable;
 
       // use x and y variable from content
@@ -84,17 +94,4 @@
     }
 
-    protected override void OnContentChanged() {
-      base.OnContentChanged();
-      if (Content != null) {
-        InitData();
-      }
-    }
-
-    protected override void SetEnabledStateOfControls() {
-      base.SetEnabledStateOfControls();
-      useGradientCheckBox.Enabled = (string)comboBoxGroup.SelectedItem != NoGroupItem;
-      gradientPanel.Visible = useGradientCheckBox.Enabled && useGradientCheckBox.Checked; ;
-    }
-
     private void UpdateScatterPlot() {
       if (comboBoxXVariable.SelectedItem != null && comboBoxYVariable.SelectedItem != null && comboBoxGroup.SelectedItem != null) {
@@ -103,13 +100,6 @@
         var groupVariable = (string)comboBoxGroup.SelectedItem;
 
-        bool isGroupingActive = groupVariable != NoGroupItem;
-        double min = 0, max = 1;
-        if (isGroupingActive) {
-          var groupValues = Content.PreprocessingData.GetValues<double>(Content.PreprocessingData.GetColumnIndex(groupVariable))
-            .Distinct().OrderBy(x => x).ToList();
-          min = groupValues.FirstOrDefault(x => !double.IsNaN(x));
-          max = groupValues.LastOrDefault(x => !double.IsNaN(x));
-        }
         ScatterPlot scatterPlot = Content.CreateScatterPlot(xVariable, yVariable, groupVariable);
+        //rows are saved and removed to avoid firing of visual property changed events
         var rows = scatterPlot.Rows.ToList();
         scatterPlot.Rows.Clear();
@@ -122,6 +112,4 @@
           row.VisualProperties.PolynomialRegressionOrder = order;
           row.VisualProperties.IsVisibleInLegend = !useGradientCheckBox.Checked;
-          if (isGroupingActive && useGradientCheckBox.Checked)
-            row.VisualProperties.Color = GetColor(double.Parse(row.Name), min, max);
         }
         scatterPlot.Rows.AddRange(rows);
@@ -133,9 +121,4 @@
         scatterPlotControl.Content = scatterPlot;
 
-        if (isGroupingActive) {
-          gradientMinimumLabel.Text = min.ToString("G5");
-          gradientMaximumLabel.Text = max.ToString("G5");
-        }
-
         //save selected x and y variable in content
         this.Content.SelectedXVariable = (string)comboBoxXVariable.SelectedItem;
@@ -149,5 +132,4 @@
       UpdateScatterPlot();
       var newPlot = scatterPlotControl.Content;
-
 
       if (oldPlot == null || newPlot == null) return;
@@ -183,5 +165,5 @@
 
     private void comboBoxGroup_SelectedIndexChanged(object sender, EventArgs e) {
-      useGradientCheckBox.Enabled = (string)comboBoxGroup.SelectedItem != NoGroupItem;
+      useGradientCheckBox.Enabled = (string)comboBoxGroup.SelectedItem != NoGroupItem && Content.PreprocessingData.GetDoubleVariableNames().Contains((string)comboBoxGroup.SelectedItem);
       gradientPanel.Visible = useGradientCheckBox.Enabled && useGradientCheckBox.Checked;
       UpdateScatterPlot();
@@ -201,9 +183,11 @@
 
     private void UpdateRegressionLine() {
+      if (Content == null) return;
+      scatterPlotControl.Content.Rows.Clear();
+
       var regressionType = (RegressionType)regressionTypeComboBox.SelectedValue;
       int order = (int)polynomialRegressionOrderNumericUpDown.Value;
 
       var rows = scatterPlotControl.Content.Rows.ToList();
-      scatterPlotControl.Content.Rows.Clear();
       foreach (var row in rows) {
         row.VisualProperties.IsRegressionVisibleInLegend = false;
@@ -258,13 +242,20 @@
     }
 
-    private void BatchRowUpdate(Action<ScatterPlotDataRow> rowAction) {
-      var scatterPlot = scatterPlotControl.Content;
-      var rows = scatterPlot.Rows.ToList();
-      // remove rows and re-add them later to avoid firing visual property changd events
-      scatterPlot.Rows.Clear();
-      foreach (var row in rows) {
-        rowAction(row);
-      }
-      scatterPlot.Rows.AddRange(rows);
+    private static IEnumerable<string> GetVariableNamesForGrouping(IPreprocessingData preprocessingData) {
+      var variableNames = new List<string>();
+
+      for (int i = 0; i < preprocessingData.Columns; ++i) {
+        int distinctValues = Int32.MaxValue;
+        if (preprocessingData.VariableHasType<double>(i))
+          distinctValues = preprocessingData.GetValues<double>(i).GroupBy(x => x).Count();
+        else if (preprocessingData.VariableHasType<string>(i))
+          distinctValues = preprocessingData.GetValues<string>(i).GroupBy(x => x).Count();
+        else if (preprocessingData.VariableHasType<DateTime>(i))
+          distinctValues = preprocessingData.GetValues<DateTime>(i).GroupBy(x => x).Count();
+
+        if (distinctValues <= MAX_DISTINCT_VALUES_FOR_GROUPING)
+          variableNames.Add(preprocessingData.GetVariableName(i));
+      }
+      return variableNames;
     }
   }
Index: /branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/ScatterPlotContent.cs
===================================================================
--- /branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/ScatterPlotContent.cs	(revision 14723)
+++ /branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/ScatterPlotContent.cs	(revision 14724)
@@ -25,5 +25,4 @@
 using HeuristicLab.Analysis;
 using HeuristicLab.Common;
-using HeuristicLab.Problems.DataAnalysis;
 using HeuristicLab.Visualization.ChartControlsExtensions;
 
@@ -55,5 +54,6 @@
           scatterPlot.VisualProperties.XAxisMinimumFixedValue = axisMin;
           scatterPlot.VisualProperties.XAxisMaximumFixedValue = axisMax;
-        } catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval 
+        }
+        catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval 
         try {
           double axisMin, axisMax, axisInterval;
@@ -63,45 +63,41 @@
           scatterPlot.VisualProperties.YAxisMinimumFixedValue = axisMin;
           scatterPlot.VisualProperties.YAxisMaximumFixedValue = axisMax;
-        } catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval 
+        }
+        catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval 
       }
 
-      if (variableNameGroup == null || variableNameGroup == "-") {
+
+      //No Grouping
+      if (string.IsNullOrEmpty(variableNameGroup) || variableNameGroup == "-") {
         ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", validPoints);
         scdr.VisualProperties.IsVisibleInLegend = false;
         scatterPlot.Rows.Add(scdr);
-      } else {
-        var groupValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameGroup));
-        var data = points.Zip(groupValues, (p, g) => new { p, g })
-          .Where(x => !double.IsNaN(x.p.X) && !double.IsNaN(x.p.Y) && !double.IsInfinity(x.p.X) && !double.IsInfinity(x.p.Y))
-          .ToList();
+        return scatterPlot;
+      }
 
-        foreach (var groupValue in groupValues.Distinct().OrderBy(g => g)) {
-          var values = data.Where(x => x.g == groupValue || (double.IsNaN(x.g) && double.IsNaN(groupValue))).Select(v => v.p);
-          var row = new ScatterPlotDataRow(string.Format("{0} ({1})", variableNameGroup, groupValue), "", values) {
-            Name = groupValue.ToString("R"),
-            VisualProperties = { PointSize = 6 }
-          };
-          scatterPlot.Rows.Add(row);
-        }
+      //Grouping
+      int groupVariableIndex = PreprocessingData.GetColumnIndex(variableNameGroup);
+      var groupingValues = Enumerable.Empty<string>();
+
+      if (PreprocessingData.VariableHasType<double>(groupVariableIndex)) {
+        groupingValues = PreprocessingData.GetValues<double>(groupVariableIndex).Select(x => x.ToString());
+      } else if (PreprocessingData.VariableHasType<string>(groupVariableIndex)) {
+        groupingValues = PreprocessingData.GetValues<string>(groupVariableIndex);
+      } else if (PreprocessingData.VariableHasType<DateTime>(groupVariableIndex)) {
+        groupingValues = PreprocessingData.GetValues<DateTime>(groupVariableIndex).Select(x => x.ToString());
+      }
+      var groups = groupingValues.Zip(validPoints, Tuple.Create).GroupBy(t => t.Item1, t => t.Item2);
+
+      foreach (var group in groups) {
+        var scdr = new ScatterPlotDataRow();
+        scdr.Name = group.Key;
+        scdr.VisualProperties.IsVisibleInLegend = true;
+        scdr.VisualProperties.PointSize = 6;
+        scdr.Points.AddRange(group);
+        scatterPlot.Rows.Add(scdr);
       }
       return scatterPlot;
     }
 
-    public DataRow GetCorrelationRow(string variableNameX, string variableNameY) {
-      var xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX));
-      var yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY));
-
-      double k, d;
-      OnlineCalculatorError err;
-      OnlineLinearScalingParameterCalculator.Calculate(xValues, yValues, out k, out d, out err);
-      double p = OnlinePearsonsRCalculator.Calculate(xValues, yValues, out err);
-
-      var data = new double[xValues.Count];
-      for (int i = 0; i < xValues.Count; i++) {
-        data[i]= k * i + d;
-      }
-
-      return new DataRow(string.Format("Correlation (R²={0})", p*p), "", data);
-    }
   }
 }
