Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GpPluginsRefactoringBranch/HeuristicLab.CEDMA.Charting/ResultListView.cs @ 644

Last change on this file since 644 was 571, checked in by gkronber, 16 years ago

implemented basic histogram (without 'brushing'). #271 (Functionality to show frequency distribution of any variable (histograms))

File size: 3.6 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 HeuristicLab.Core;
10using HeuristicLab.Charting;
11
12namespace HeuristicLab.CEDMA.Charting {
13  public partial class ResultListView : ViewBase {
14    private ResultList results;
15    private const string FREQUENCY = "<Frequency>";
16    private const string CONSTANT_SIZE = "<constant>";
17    private BubbleChartControl bubbleChartControl;
18    private HistogramControl histogramControl;
19    private Label pleaseSelectAxisLabel = new Label();
20
21    public ResultListView(ResultList results) {
22      this.results = results;
23      InitializeComponent();
24      InitCharts();
25      xAxisComboBox.Items.AddRange(results.VariableNames);
26      yAxisComboBox.Items.Add(FREQUENCY);
27      yAxisComboBox.Items.AddRange(results.VariableNames);
28      sizeComboBox.Items.Add(CONSTANT_SIZE);
29      sizeComboBox.Items.AddRange(results.VariableNames);
30      sizeComboBox.SelectedItem = sizeComboBox.Items[0];
31      sizeComboBox.Enabled = false;
32      invertCheckbox.Enabled = false;
33      sizeLabel.Enabled = false;
34      yAxisComboBox.SelectedItem = yAxisComboBox.Items[0];
35      xAxisComboBox.SelectedItem = xAxisComboBox.Items[0];
36    }
37
38    private void InitCharts() {
39      bubbleChartControl = new BubbleChartControl();
40      bubbleChartControl.Chart = new BubbleChart(results, 0, 0, 100, 100);
41      histogramControl = new HistogramControl();
42      histogramControl.Chart = new Histogram(results, 0, 0, 100, 100);
43    }
44
45    private void yAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) {
46      UpdateChart();
47    }
48
49    private void xAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) {
50      UpdateChart();
51    }
52
53    private void UpdateChart() {
54      if(xAxisComboBox.SelectedItem == null || yAxisComboBox.SelectedItem == null) return;
55      if(yAxisComboBox.SelectedItem.Equals(FREQUENCY)) {
56        xJitterlabel.Enabled = false;
57        xTrackBar.Enabled = false;
58        yJitterLabel.Enabled = false;
59        yTrackBar.Enabled = false;
60        sizeComboBox.Enabled = false;
61        invertCheckbox.Enabled = false;
62        sizeLabel.Enabled = false;
63        chartPanel.Controls.Clear();
64        chartPanel.Controls.Add(histogramControl);
65        histogramControl.Chart.ShowFrequency((string)xAxisComboBox.SelectedItem);
66        histogramControl.Dock = DockStyle.Fill;
67      } else {
68        xJitterlabel.Enabled = true;
69        xTrackBar.Enabled = true;
70        yJitterLabel.Enabled = true;
71        yTrackBar.Enabled = true;
72        sizeComboBox.Enabled = true;
73        invertCheckbox.Enabled = true;
74        sizeLabel.Enabled = true;
75        chartPanel.Controls.Clear();
76        chartPanel.Controls.Add(bubbleChartControl);
77        bubbleChartControl.Chart.ShowXvsY((string)xAxisComboBox.SelectedItem, (string)yAxisComboBox.SelectedItem);
78        bubbleChartControl.Dock = DockStyle.Fill;
79      }
80    }
81
82    private void jitterTrackBar_ValueChanged(object sender, EventArgs e) {
83      if(bubbleChartControl.Chart != null) {
84        double xJitterFactor = xTrackBar.Value / 100.0;
85        double yJitterFactor = yTrackBar.Value / 100.0;
86        bubbleChartControl.Chart.SetJitter(xJitterFactor, yJitterFactor);
87      }
88      UpdateChart();
89    }
90
91    private void sizeComboBox_SelectedIndexChanged(object sender, EventArgs e) {
92      if(bubbleChartControl.Chart != null) {
93        bubbleChartControl.Chart.SetBubbleSizeDimension((string)sizeComboBox.SelectedItem, invertCheckbox.Checked);
94        UpdateChart();
95      }
96    }
97  }
98}
Note: See TracBrowser for help on using the repository browser.