Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/03/12 15:33:08 (13 years ago)
Author:
sforsten
Message:

#1811:

  • deleted toggle of series
Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.Designer.cs

    r7700 r7701  
    4949      this.chart.TabIndex = 0;
    5050      this.chart.Text = "chart";
    51       this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend);
    5251      this.chart.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.Chart_MouseDoubleClick);
    5352      this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
    54       this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
    5553      //
    5654      // label1
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs

    r7700 r7701  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Drawing;
    2524using System.Linq;
    2625using System.Windows.Forms;
     
    2827using HeuristicLab.MainForm;
    2928using HeuristicLab.MainForm.WindowsForms;
     29
    3030namespace HeuristicLab.Problems.DataAnalysis.Views {
    3131  [View("Error Characteristics Curve")]
     
    3737    protected const string AllSamples = "All Samples";
    3838
    39     protected Dictionary<string, List<double>> seriesResiduals = new Dictionary<string, List<double>>();
    40 
    4139    public RegressionSolutionErrorCharacteristicsCurveView()
    4240      : base() {
     
    102100    protected virtual void UpdateChart() {
    103101      chart.Series.Clear();
    104       seriesResiduals.Clear();
    105102      chart.Annotations.Clear();
    106103      if (Content == null) return;
     
    117114      Series baselineSeries = new Series("Baseline");
    118115      baselineSeries.ChartType = SeriesChartType.FastLine;
    119       seriesResiduals[baselineSeries.Name] = baselineResiduals;
    120116      UpdateSeries(baselineResiduals, baselineSeries);
    121117      baselineSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(baselineSeries);
     
    133129      solutionSeries.ChartType = SeriesChartType.FastLine;
    134130      var estimatedValues = GetResiduals(GetOriginalValues(), GetEstimatedValues(solution));
    135       seriesResiduals[solutionSeries.Name] = estimatedValues;
    136131      UpdateSeries(estimatedValues, solutionSeries);
    137132      solutionSeries.ToolTip = "Area over Curve: " + CalculateAreaOverCurve(solutionSeries);
     
    235230    }
    236231
    237     #region events
     232    #region Baseline
    238233    private void Chart_MouseDoubleClick(object sender, MouseEventArgs e) {
    239234      HitTestResult result = chart.HitTest(e.X, e.Y);
    240235      if (result.ChartElementType != ChartElementType.LegendItem) return;
    241       if (result.Series.Name != constantModel.Name) return;
    242236
    243237      MainFormManager.MainForm.ShowContent((IRegressionSolution)result.Series.Tag);
    244238    }
     239
     240    private IRegressionSolution CreateConstantModel() {
     241      double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes).Average();
     242      var solution = new ConstantRegressionModel(averageTrainingTarget).CreateRegressionSolution(ProblemData);
     243      solution.Name = "Baseline";
     244      return solution;
     245    }
     246    #endregion
     247
    245248    private void chart_MouseMove(object sender, MouseEventArgs e) {
    246249      HitTestResult result = chart.HitTest(e.X, e.Y);
     
    250253        Cursor = Cursors.Default;
    251254    }
    252     private void chart_MouseDown(object sender, MouseEventArgs e) {
    253       HitTestResult result = chart.HitTest(e.X, e.Y);
    254       if (result.ChartElementType == ChartElementType.LegendItem) {
    255         ToggleSeriesData(result.Series);
    256       }
    257     }
    258     private void chart_CustomizeLegend(object sender, CustomizeLegendEventArgs e) {
    259       foreach (LegendItem legend in e.LegendItems) {
    260         legend.Cells[1].ForeColor = this.chart.Series[legend.SeriesName].Points.Count == 0 ? Color.Gray : Color.Black;
    261       }
    262     }
    263     #endregion
    264 
    265     private IRegressionSolution CreateConstantModel() {
    266       double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes).Average();
    267       var solution = new ConstantRegressionModel(averageTrainingTarget).CreateRegressionSolution(ProblemData);
    268       solution.Name = "Baseline";
    269       return solution;
    270     }
    271 
    272     private void ToggleSeriesData(Series series) {
    273       if (series.Points.Count > 0) {  //checks if series is shown
    274         if (this.chart.Series.Any(s => s != series && s.Points.Count > 0)) {
    275           ClearPointsQuick(series.Points);
    276         }
    277       } else if (Content != null) {
    278         List<double> residuals;
    279         if (seriesResiduals.TryGetValue(series.Name, out residuals)) {
    280           UpdateSeries(residuals, series);
    281           chart.Legends[series.Legend].ForeColor = Color.Black;
    282           chart.Refresh();
    283         }
    284       }
    285     }
    286 
    287     // workaround as per http://stackoverflow.com/questions/5744930/datapointcollection-clear-performance
    288     private static void ClearPointsQuick(DataPointCollection points) {
    289       points.SuspendUpdates();
    290       while (points.Count > 0)
    291         points.RemoveAt(points.Count - 1);
    292       points.ResumeUpdates();
    293     }
    294255  }
    295256}
Note: See TracChangeset for help on using the changeset viewer.