Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/MultiScatterPlotView.cs @ 10882

Last change on this file since 10882 was 10882, checked in by aesterer, 10 years ago

Added scatter plot view

File size: 2.0 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.Analysis;
10using HeuristicLab.Analysis.Views;
11using HeuristicLab.Collections;
12using HeuristicLab.Core;
13using HeuristicLab.Core.Views;
14using HeuristicLab.Data;
15using HeuristicLab.DataPreprocessing.Implementations;
16using HeuristicLab.MainForm;
17
18namespace HeuristicLab.DataPreprocessing.Views {
19
20  [View("Scatter Plot View")]
21  [Content(typeof(ScatterPlotContent), false)]
22  public partial class MultiScatterPlotView : ItemView {
23
24    private IChartLogic logic;
25
26    public MultiScatterPlotView() {
27      InitializeComponent();
28    }
29
30    public new ScatterPlotContent Content {
31      get { return (ScatterPlotContent)base.Content; }
32      set { base.Content = value; }
33    }
34
35    public void InitData() {
36
37      IEnumerable<string> variables = logic.GetVariableNames();
38      comboBoxXVariable.Items.Clear();
39      comboBoxYVariable.Items.Clear();
40
41      comboBoxXVariable.Items.AddRange(variables.ToArray());
42      comboBoxYVariable.Items.AddRange(variables.ToArray());
43
44      if (variables.Count() >= 2) {
45        comboBoxXVariable.SelectedIndex = 0;
46        comboBoxYVariable.SelectedIndex = 1;
47        UpdateScatterPlot();
48       
49      }
50
51    }
52
53    protected override void OnContentChanged() {
54      base.OnContentChanged();
55      if (Content != null) {
56        logic = Content.ChartLogic;
57        InitData();
58      }
59    }
60
61    private void comboBox_SelectedIndexChanged(object sender, EventArgs e) {
62      UpdateScatterPlot();
63    }
64
65    private void UpdateScatterPlot() {
66      if (comboBoxXVariable.SelectedItem != null && comboBoxYVariable.SelectedItem != null) {
67        ScatterPlot scatterPlot = logic.CreateScatterPlot("ScatterPlot", (string)comboBoxXVariable.SelectedItem, (string)comboBoxYVariable.SelectedItem);
68        scatterPlotView.Content = scatterPlot;
69      }
70    }
71
72  }
73
74 
75}
Note: See TracBrowser for help on using the repository browser.