Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/12/16 15:11:30 (9 years ago)
Author:
pfleck
Message:

#2597

  • Added a manual y-axis control.
  • Fixed bug with dragging the cursor in the GradientChart out of the chart.
Location:
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/DensityTrackbar.Designer.cs

    r13824 r13846  
    9191            | System.Windows.Forms.AnchorStyles.Left)
    9292            | System.Windows.Forms.AnchorStyles.Right)));
    93       this.chart.BorderlineColor = System.Drawing.Color.Transparent;
    9493      chartArea1.AxisX.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.False;
    9594      chartArea1.AxisX.IsMarginVisible = false;
     
    9897      chartArea1.AxisY.MajorTickMark.Enabled = false;
    9998      chartArea1.AxisY.Minimum = 0D;
    100       chartArea1.BackColor = System.Drawing.Color.Transparent;
    101       chartArea1.BorderColor = System.Drawing.Color.Transparent;
     99      chartArea1.BackColor = System.Drawing.Color.White;
     100      chartArea1.BorderColor = System.Drawing.Color.White;
    102101      chartArea1.Name = "ChartArea1";
    103102      chartArea1.Position.Auto = false;
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/DensityTrackbar.cs

    r13824 r13846  
    141141        LimitsChanged(this, EventArgs.Empty);
    142142    }
    143 
    144143    #region Hepers
    145144
     
    166165
    167166    #endregion
    168 
    169 
    170167  }
    171168}
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/GradientChart.cs

    r13845 r13846  
    526526    private double oldCurserPosition = double.NaN;
    527527    private void chart_AnnotationPositionChanging(object sender, AnnotationPositionChangingEventArgs e) {
    528       if (oldCurserPosition.IsAlmost(e.NewLocationX))
    529         return;
    530       oldCurserPosition = e.NewLocationX;
    531 
    532528      var step = (trainingMax - trainingMin) / drawingSteps;
    533       e.NewLocationX = step * (long)Math.Round(e.NewLocationX / step);
     529      double newLocation = step * (long)Math.Round(e.NewLocationX / step);
    534530      var axisX = chart.ChartAreas[0].AxisX;
    535       if (e.NewLocationX > axisX.Maximum)
    536         e.NewLocationX = axisX.Maximum;
    537       if (e.NewLocationX < axisX.Minimum)
    538         e.NewLocationX = axisX.Minimum;
     531      if (newLocation > axisX.Maximum)
     532        newLocation = axisX.Maximum;
     533      if (newLocation < axisX.Minimum)
     534        newLocation = axisX.Minimum;
     535
     536      e.NewLocationX = newLocation;
    539537
    540538      var annotation = VerticalLineAnnotation;
     
    545543      chart.Update();
    546544
    547       OnVariableValueChanged(this, EventArgs.Empty);
     545      if (!oldCurserPosition.IsAlmost(e.NewLocationX))
     546        OnVariableValueChanged(this, EventArgs.Empty);
     547      oldCurserPosition = e.NewLocationX;
    548548    }
    549549
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/RegressionSolutionGradientView.cs

    r13842 r13846  
    2626using HeuristicLab.Collections;
    2727using HeuristicLab.MainForm;
     28using HeuristicLab.MainForm.WindowsForms;
    2829using HeuristicLab.Problems.DataAnalysis;
    2930using HeuristicLab.Problems.DataAnalysis.Views;
     
    7677      trackbars.Clear();
    7778
     79      tableLayoutPanel.SuspendRepaint();
     80      tableLayoutPanel.SuspendLayout();
     81
    7882      tableLayoutPanel.RowCount = 0;
    7983      tableLayoutPanel.Controls.Clear();
    8084
    81       if (Content == null) return;
     85      if (Content == null) {
     86        tableLayoutPanel.ResumeLayout(false);
     87        tableLayoutPanel.ResumeRepaint(false);
     88        return;
     89      }
    8290
    8391      variableNames.AddRange(Content.ProblemData.AllowedInputVariables);
     
    99107      }
    100108
     109      tableLayoutPanel.ResumeLayout(true);
     110      tableLayoutPanel.ResumeRepaint(true);
     111
    101112      trackbars.First().Checked = true;
    102113    }
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/RegressionSolutionTargetResponseGradientView.Designer.cs

    r13817 r13846  
    2727      this.panel1 = new System.Windows.Forms.Panel();
    2828      this.gradientChartTableLayout = new System.Windows.Forms.TableLayoutPanel();
     29      this.yAxisConfigGroupBox = new System.Windows.Forms.GroupBox();
     30      this.limitView = new HeuristicLab.Problems.DataAnalysis.Views.DoubleLimitView();
     31      this.automaticYAxisCheckBox = new System.Windows.Forms.CheckBox();
    2932      this.panel1.SuspendLayout();
     33      this.yAxisConfigGroupBox.SuspendLayout();
    3034      this.SuspendLayout();
    3135      //
     
    6973      this.gradientChartTableLayout.RowCount = 1;
    7074      this.gradientChartTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 693F));
    71       this.gradientChartTableLayout.Size = new System.Drawing.Size(848, 693);
     75      this.gradientChartTableLayout.Size = new System.Drawing.Size(828, 693);
    7276      this.gradientChartTableLayout.TabIndex = 2;
     77      //
     78      // yAxisConfigGroupBox
     79      //
     80      this.yAxisConfigGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     81      this.yAxisConfigGroupBox.Controls.Add(this.limitView);
     82      this.yAxisConfigGroupBox.Controls.Add(this.automaticYAxisCheckBox);
     83      this.yAxisConfigGroupBox.Location = new System.Drawing.Point(4, 342);
     84      this.yAxisConfigGroupBox.Name = "yAxisConfigGroupBox";
     85      this.yAxisConfigGroupBox.Size = new System.Drawing.Size(152, 98);
     86      this.yAxisConfigGroupBox.TabIndex = 2;
     87      this.yAxisConfigGroupBox.TabStop = false;
     88      this.yAxisConfigGroupBox.Text = "Y-Axis";
     89      //
     90      // limitView
     91      //
     92      this.limitView.Caption = "DoubleLimit View";
     93      this.limitView.Content = null;
     94      this.limitView.Location = new System.Drawing.Point(6, 20);
     95      this.limitView.Name = "limitView";
     96      this.limitView.ReadOnly = false;
     97      this.limitView.Size = new System.Drawing.Size(140, 47);
     98      this.limitView.TabIndex = 1;
     99      //
     100      // automaticYAxisCheckBox
     101      //
     102      this.automaticYAxisCheckBox.AutoSize = true;
     103      this.automaticYAxisCheckBox.Location = new System.Drawing.Point(6, 72);
     104      this.automaticYAxisCheckBox.Name = "automaticYAxisCheckBox";
     105      this.automaticYAxisCheckBox.Size = new System.Drawing.Size(73, 17);
     106      this.automaticYAxisCheckBox.TabIndex = 0;
     107      this.automaticYAxisCheckBox.Text = "Automatic";
     108      this.automaticYAxisCheckBox.UseVisualStyleBackColor = true;
    73109      //
    74110      // RegressionSolutionTargetResponseGradientView
     
    76112      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    77113      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     114      this.Controls.Add(this.yAxisConfigGroupBox);
    78115      this.Controls.Add(this.panel1);
    79116      this.Controls.Add(this.variableListView);
     
    82119      this.panel1.ResumeLayout(false);
    83120      this.panel1.PerformLayout();
     121      this.yAxisConfigGroupBox.ResumeLayout(false);
     122      this.yAxisConfigGroupBox.PerformLayout();
    84123      this.ResumeLayout(false);
    85124
     
    91130    private System.Windows.Forms.Panel panel1;
    92131    private System.Windows.Forms.TableLayoutPanel gradientChartTableLayout;
     132    private System.Windows.Forms.GroupBox yAxisConfigGroupBox;
     133    private System.Windows.Forms.CheckBox automaticYAxisCheckBox;
     134    private DoubleLimitView limitView;
    93135  }
    94136}
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/RegressionSolutionTargetResponseGradientView.cs

    r13845 r13846  
    4343      InitializeComponent();
    4444      charts = new Dictionary<string, GradientChart>();
     45
     46      limitView.Content = new DoubleLimit(0, 1);
    4547    }
    4648
     
    5355      base.RegisterContentEvents();
    5456      variableListView.ItemChecked += variableListView_ItemChecked;
     57      limitView.Content.ValueChanged += limit_ValueChanged;
     58      automaticYAxisCheckBox.CheckedChanged += automaticYAxisCheckBox_CheckedChanged;
    5559    }
    5660
    5761    protected override void DeregisterContentEvents() {
    5862      variableListView.ItemChecked -= variableListView_ItemChecked;
     63      limitView.Content.ValueChanged -= limit_ValueChanged;
     64      automaticYAxisCheckBox.CheckedChanged -= automaticYAxisCheckBox_CheckedChanged;
    5965      base.DeregisterContentEvents();
    6066    }
     
    6470      if (Content == null) return;
    6571      var problemData = Content.ProblemData;
     72
     73      // Init Y-axis range
     74      double min = double.MaxValue, max = double.MinValue;
     75      var trainingTarget = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices);
     76      foreach (var t in trainingTarget) {
     77        if (t < min) min = t;
     78        if (t > max) max = t;
     79      }
     80      double range = max - min;
     81      const double scale = 1.0 / 3.0;
     82      double axisMin, axisMax, axisInterval;
     83      ChartUtil.CalculateAxisInterval(min - scale * range, max + scale * range, 5, out axisMin, out axisMax, out axisInterval);
     84      automaticYAxisCheckBox.Checked = false;
     85      limitView.ReadOnly = false;
     86      limitView.Content.Lower = axisMin;
     87      limitView.Content.Upper = axisMax;
     88
    6689      // create dataset
    6790      var allowedInputVariables = Content.ProblemData.AllowedInputVariables;
     
    87110
    88111          if (recalculations.All(t => t.IsCompleted))
    89             SyncYAxis();
     112            SetupYAxis();
    90113        };
    91114        gradientChart.Configure(new[] { Content }, sharedFixedVariables, variableName, Points);
     
    101124    }
    102125
    103     private void SyncYAxis() {
    104       double min = double.MaxValue, max = double.MinValue;
    105       foreach (var chart in VisibleCharts) {
    106         if (chart.YMin < min) min = chart.YMin;
    107         if (chart.YMax > max) max = chart.YMax;
    108       }
    109       double axisMin, axisMax, axisInterval;
    110       ChartUtil.CalculateAxisInterval(min, max, 5, out axisMin, out axisMax, out axisInterval);
     126    private void SetupYAxis() {
     127      double axisMin, axisMax;
     128      if (automaticYAxisCheckBox.Checked) {
     129        double min = double.MaxValue, max = double.MinValue;
     130        foreach (var chart in VisibleCharts) {
     131          if (chart.YMin < min) min = chart.YMin;
     132          if (chart.YMax > max) max = chart.YMax;
     133        }
     134
     135        double axisInterval;
     136        ChartUtil.CalculateAxisInterval(min, max, 5, out axisMin, out axisMax, out axisInterval);
     137      } else {
     138        axisMin = limitView.Content.Lower;
     139        axisMax = limitView.Content.Upper;
     140      }
    111141
    112142      foreach (var chart in VisibleCharts) {
     
    146176        tl.Controls.Remove(chart);
    147177      }
    148       SyncYAxis();
     178      SetupYAxis();
    149179
    150180      var count = tl.Controls.Count;
     
    163193      tl.ResumeLayout();
    164194    }
     195
     196    private void automaticYAxisCheckBox_CheckedChanged(object sender, EventArgs e) {
     197      limitView.ReadOnly = automaticYAxisCheckBox.Checked;
     198      SetupYAxis();
     199    }
     200
     201    private void limit_ValueChanged(object sender, EventArgs e) {
     202      if (automaticYAxisCheckBox.Checked)
     203        return;
     204      SetupYAxis();
     205    }
    165206  }
    166207}
Note: See TracChangeset for help on using the changeset viewer.