source: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Charting/BubbleChartView.cs @ 1108

Last change on this file since 1108 was 1108, checked in by gkronber, 12 years ago

worked on CEDMA presentation layer (bubble chart, and collection of results) (#419)

File size: 2.5 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.CEDMA.Charting;
11using HeuristicLab.CEDMA.Core;
12
13namespace HeuristicLab.CEDMA.Charting {
14  public partial class BubbleChartView : ViewBase, IResultsView {
15    private Results results;
16    private const string CONSTANT_SIZE = "<constant>";
17    private Label pleaseSelectAxisLabel = new Label();
18
19    public BubbleChartView() {
20      InitializeComponent();
21    }
22
23    private void axisComboBox_SelectedIndexChanged(object sender, EventArgs e) {
24      UpdateChart();
25    }
26
27    private void UpdateChart() {
28      if (xAxisComboBox.SelectedItem == null || yAxisComboBox.SelectedItem == null) return;
29      bubbleChartControl.Chart.ShowXvsY((string)xAxisComboBox.SelectedItem, (string)yAxisComboBox.SelectedItem);
30    }
31
32    private void jitterTrackBar_ValueChanged(object sender, EventArgs e) {
33      if (bubbleChartControl.Chart != null) {
34        double xJitterFactor = xTrackBar.Value / 100.0;
35        double yJitterFactor = yTrackBar.Value / 100.0;
36        bubbleChartControl.Chart.SetJitter(xJitterFactor, yJitterFactor);
37      }
38      UpdateChart();
39    }
40
41    private void sizeComboBox_SelectedIndexChanged(object sender, EventArgs e) {
42      if (bubbleChartControl.Chart != null) {
43        bubbleChartControl.Chart.SetBubbleSizeDimension((string)sizeComboBox.SelectedItem, invertCheckbox.Checked);
44        UpdateChart();
45      }
46    }
47
48    #region IResultsView Members
49
50    public Control Control {
51      get { return this; }
52    }
53
54    string IResultsView.Name {
55      get { return "Bubble chart"; }
56    }
57
58    public void ShowResults(Results results) {
59      this.results = results;
60      bubbleChartControl.Chart = new BubbleChart(results, 0, 0, 100, 100);
61      xAxisComboBox.Items.AddRange(Results.OrdinalVariables);
62      xAxisComboBox.Items.AddRange(Results.CategoricalVariables);
63      yAxisComboBox.Items.AddRange(Results.OrdinalVariables);
64      yAxisComboBox.Items.AddRange(Results.CategoricalVariables);
65      sizeComboBox.Items.Add(CONSTANT_SIZE);
66      sizeComboBox.Items.AddRange(Results.OrdinalVariables);
67      sizeComboBox.SelectedItem = sizeComboBox.Items[0];
68      yAxisComboBox.SelectedItem = yAxisComboBox.Items[0];
69      xAxisComboBox.SelectedItem = xAxisComboBox.Items[0];
70    }
71
72    #endregion
73  }
74}
Note: See TracBrowser for help on using the repository browser.