Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/VariableTrackbar.cs @ 8876

Last change on this file since 8876 was 7028, checked in by gkronber, 13 years ago

#1621: fixed bugs in response function view and added scatter plot of original data as a reference.

File size: 2.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9using System.Windows.Forms.DataVisualization.Charting;
10using HeuristicLab.Common;
11
12namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
13  public partial class VariableTrackbar : UserControl {
14    private readonly string variableName;
15    private const double FACTOR = 1000;
16
17    public double Value {
18      get { return trackBar.Value / FACTOR; }
19    }
20
21    public string VariableName {
22      get { return variableName; }
23    }
24
25    public VariableTrackbar(string variableName, IEnumerable<double> values) {
26      InitializeComponent();
27      this.variableName = variableName;
28      groupBox.Text = variableName;
29      var valuesArr = values.ToArray();
30      this.valueTextBox.Text = string.Format("{0:0.000e+00}", valuesArr.Median());
31      boxPlotChart.Series["DataSeries"].Points.Clear();
32      boxPlotChart.Series["DataSeries"].Points.DataBindY(valuesArr);
33      boxPlotChart.Series["BoxPlot"].ChartType = SeriesChartType.BoxPlot;
34      boxPlotChart.Series["BoxPlot"]["BoxPlotSeries"] = "DataSeries";
35      boxPlotChart.Series["BoxPlot"]["BoxPlotWhiskerPercentile"] = "5";
36      boxPlotChart.Series["BoxPlot"]["BoxPlotPercentile"] = "30";
37      boxPlotChart.Series["BoxPlot"]["BoxPlotShowAverage"] = "true";
38      boxPlotChart.Series["BoxPlot"]["BoxPlotShowMedian"] = "true";
39      boxPlotChart.Series["BoxPlot"]["BoxPlotShowUnusualValues"] = "true";
40      boxPlotChart.ChartAreas[0].AxisY.Minimum = valuesArr.Min() ;
41      boxPlotChart.ChartAreas[0].AxisY.Maximum = valuesArr.Max() ;
42     
43
44      trackBar.Minimum = (int)Math.Round(valuesArr.Min() * FACTOR);
45      trackBar.Maximum = (int)Math.Round(valuesArr.Max() * FACTOR);
46      trackBar.Value = (int)Math.Round(valuesArr.Median() * FACTOR);
47      trackBar.TickStyle = TickStyle.None;
48      trackBar.Tag = variableName;
49    }
50
51    private void TrackBarValueChanged(object sender, EventArgs e) {
52      valueTextBox.Text = string.Format("{0:0.000e+00}", trackBar.Value / FACTOR);
53      RaiseValueChanged(EventArgs.Empty);
54    }
55
56    public event EventHandler ValueChanged;
57    private void RaiseValueChanged(EventArgs e) {
58      var handler = ValueChanged;
59      if (handler != null) handler(this, e);
60    }
61  }
62}
Note: See TracBrowser for help on using the repository browser.