Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/21/16 11:26:54 (7 years ago)
Author:
pfleck
Message:

#2709

  • Added a VerticalLabel for the multi-scatterplot.
  • Added regression options for single- and multi-scatterplot
File:
1 edited

Legend:

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

    r14511 r14514  
    1010using HeuristicLab.MainForm;
    1111using HeuristicLab.MainForm.WindowsForms;
     12using RegressionType = HeuristicLab.Analysis.ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType;
    1213
    1314namespace HeuristicLab.DataPreprocessing.Views {
     
    1617  public partial class ScatterPlotMultiView : PreprocessingCheckedVariablesView {
    1718    private readonly IDictionary<string, Label> columnHeaderCache;
    18     private readonly IDictionary<string, Label> rowHeaderCache;
     19    private readonly IDictionary<string, VerticalLabel> rowHeaderCache;
    1920    private readonly IDictionary<Tuple<string/*col*/, string/*row*/>, Control> bodyCache;
    2021
    2122    public ScatterPlotMultiView() {
    2223      InitializeComponent();
     24
     25      regressionTypeComboBox.DataSource = Enum.GetValues(typeof(RegressionType));
     26      regressionTypeComboBox.SelectedItem = RegressionType.None;
    2327
    2428      #region Initialize Scrollbars
     
    4145
    4246      columnHeaderCache = new Dictionary<string, Label>();
    43       rowHeaderCache = new Dictionary<string, Label>();
     47      rowHeaderCache = new Dictionary<string, VerticalLabel>();
    4448      bodyCache = new Dictionary<Tuple<string, string>, Control>();
    4549
     
    5761        GenerateCharts();
    5862      }
     63    }
     64
     65    protected override void SetEnabledStateOfControls() {
     66      base.SetEnabledStateOfControls();
     67      var regressionType = (RegressionType)regressionTypeComboBox.SelectedValue;
     68      polynomialRegressionOrderNumericUpDown.Enabled = regressionType == RegressionType.Polynomial;
    5969    }
    6070
     
    239249    private Label GetRowHeader(string variable) {
    240250      if (!rowHeaderCache.ContainsKey(variable)) {
    241         rowHeaderCache.Add(variable, new Label() {
     251        rowHeaderCache.Add(variable, new VerticalLabel() {
    242252          Text = variable,
    243253          TextAlign = ContentAlignment.MiddleCenter,
    244254          Name = variable,
    245255          Width = rowHeaderTableLayoutPanel.Width,
     256          Height = columnHeaderScrollPanel.Width,
    246257          Dock = DockStyle.Fill,
    247258          Margin = new Padding(3)
     
    269280        } else { //scatter plot
    270281          var scatterPlot = Content.CreateScatterPlot(colVariable, rowVariable);
    271           foreach (var row in scatterPlot.Rows)
     282          var regressionType = (RegressionType)regressionTypeComboBox.SelectedValue;
     283          int order = (int)polynomialRegressionOrderNumericUpDown.Value;
     284          foreach (var row in scatterPlot.Rows) {
    272285            row.VisualProperties.PointSize = 3;
     286            row.VisualProperties.IsRegressionVisibleInLegend = false;
     287            row.VisualProperties.RegressionType = regressionType;
     288            row.VisualProperties.PolynomialRegressionOrder = order;
     289          }
    273290          scatterPlot.VisualProperties.Title = string.Empty;
    274           var scatterPlotControl = new /*Preprocessing*/ScatterPlotControl {
     291          var scatterPlotControl = new ScatterPlotControl {
    275292            Name = key.ToString(),
    276293            Content = scatterPlot,
     
    279296            //XAxisFormat = "G3"
    280297          };
    281           scatterPlotControl.DoubleClick += ScatterPlotDoubleClick; // ToDo: not working; double click is already handled by the chart
     298          //scatterPlotControl.DoubleClick += ScatterPlotDoubleClick; // ToDo: not working; double click is already handled by the chart
    282299          bodyCache.Add(key, scatterPlotControl);
    283300        }
     
    348365        c++;
    349366      }
     367      UpdateRegressionLine();
    350368    }
    351369
     
    444462    }
    445463    #endregion
     464
     465    #region Regression Line
     466    private void regressionTypeComboBox_SelectedValueChanged(object sender, EventArgs e) {
     467      var regressionType = (RegressionType)regressionTypeComboBox.SelectedValue;
     468      polynomialRegressionOrderNumericUpDown.Enabled = regressionType == RegressionType.Polynomial;
     469      UpdateRegressionLine();
     470    }
     471
     472    private void polynomialRegressionOrderNumericUpDown_ValueChanged(object sender, EventArgs e) {
     473      UpdateRegressionLine();
     474    }
     475
     476    private void UpdateRegressionLine() {
     477      var regressionType = (RegressionType)regressionTypeComboBox.SelectedValue;
     478      int order = (int)polynomialRegressionOrderNumericUpDown.Value;
     479
     480      foreach (var control in bodyCache.Values) {
     481        var scatterPlotControl = control as ScatterPlotControl;
     482        if (scatterPlotControl != null) {
     483          foreach (var row in scatterPlotControl.Content.Rows) {
     484            row.VisualProperties.IsRegressionVisibleInLegend = false;
     485            row.VisualProperties.RegressionType = regressionType;
     486            row.VisualProperties.PolynomialRegressionOrder = order;
     487          }
     488        }
     489      }
     490    }
     491    #endregion
    446492  }
    447493}
     494
Note: See TracChangeset for help on using the changeset viewer.