Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/RegressionSolutionGradientView.cs @ 13808

Last change on this file since 13808 was 13808, checked in by bburlacu, 8 years ago

#2597: Start implementing table layout panel for gradient charts in a separate view.

File size: 2.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System.Collections.Generic;
23using System.Linq;
24using System.Windows.Forms;
25using HeuristicLab.MainForm;
26
27namespace HeuristicLab.Problems.DataAnalysis.Views {
28  [View("Gradient View")]
29  [Content(typeof(IRegressionSolution))]
30  public partial class RegressionSolutionGradientView : DataAnalysisSolutionEvaluationView {
31    public RegressionSolutionGradientView() {
32      InitializeComponent();
33    }
34
35    public new IRegressionSolution Content {
36      get { return (IRegressionSolution)base.Content; }
37      set {
38        if (value == null || value == Content) return;
39        base.Content = value;
40      }
41    }
42
43    protected override void OnContentChanged() {
44      base.OnContentChanged();
45      if (Content == null) return;
46      var variable = Content.ProblemData.AllowedInputVariables.First();
47      var values = (IList<double>)Content.ProblemData.Dataset.GetReadOnlyDoubleValues(variable);
48      gradientChart1.Configure(new[] { Content }, Content.ProblemData, values.Min(), values.Max(), 1000);
49      UpdateVariableList();
50    }
51
52    protected virtual void UpdateVariableList() {
53      variableComboBox.Items.Clear();
54      var variables = Content.ProblemData.AllowedInputVariables.ToArray();
55      variableComboBox.Items.AddRange(variables);
56      variableComboBox.Text = variables[0];
57    }
58
59    private void variableComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
60      gradientChart1.Variable = variableComboBox.Text;
61    }
62  }
63}
Note: See TracBrowser for help on using the repository browser.