Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs @ 15529

Last change on this file since 15529 was 15210, checked in by pfleck, 7 years ago

#2709 Fixed some small issues and some default behavior.

File size: 3.5 KB
RevLine 
[10914]1#region License Information
2/* HeuristicLab
[14185]3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[10914]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 */
[10992]20#endregion
[13502]21
[10914]22using System;
[15110]23using System.Drawing;
[10658]24using HeuristicLab.Analysis;
25using HeuristicLab.MainForm;
26
27namespace HeuristicLab.DataPreprocessing.Views {
28  [View("Histogram View")]
[10712]29  [Content(typeof(HistogramContent), true)]
[10658]30  public partial class HistogramView : PreprocessingChartView {
[15110]31    public new HistogramContent Content {
32      get { return (HistogramContent)base.Content; }
33      set { base.Content = value; }
34    }
[10658]35
36    public HistogramView() {
37      InitializeComponent();
[15110]38      aggregationComboBox.DataSource = Enum.GetValues(typeof(DataTableVisualProperties.DataTableHistogramAggregation));
39      aggregationComboBox.SelectedItem = DataTableVisualProperties.DataTableHistogramAggregation.Overlapping;
40      orderComboBox.DataSource = Enum.GetValues(typeof(PreprocessingChartContent.LegendOrder));
[15210]41      orderComboBox.SelectedItem = PreprocessingChartContent.LegendOrder.Alphabetically;
[10658]42    }
43
[10914]44    protected override void OnContentChanged() {
[10867]45      base.OnContentChanged();
[15110]46      groupingComboBox.Items.Clear();
47      groupingComboBox.Items.Add(string.Empty);
48
[10914]49      if (Content != null) {
[15110]50        foreach (string var in PreprocessingChartContent.GetVariableNamesForGrouping(Content.PreprocessingData)) {
51          groupingComboBox.Items.Add(var);
[10867]52        }
53
[15110]54        groupingComboBox.SelectedItem = Content.GroupingVariableName ?? string.Empty;
[10867]55      }
56    }
57
[15110]58    protected override DataTable CreateDataTable(string variableName) {
59      var aggregation = (DataTableVisualProperties.DataTableHistogramAggregation)aggregationComboBox.SelectedItem;
60      var hist = HistogramContent.CreateHistogram(Content.PreprocessingData, variableName, Content.GroupingVariableName, aggregation, Content.Order);
61      hist.VisualProperties.TitleFont = new Font(DefaultFont.FontFamily, 10, FontStyle.Bold);
62      return hist;
[10658]63    }
64
[10908]65    private void classifierComboBox_SelectedIndexChanged(object sender, EventArgs e) {
[15110]66      Content.GroupingVariableName = groupingComboBox.SelectedItem.ToString();
[10736]67
[15110]68      // rebuild datatables
69      InitData();
70      GenerateLayout();
71    }
[10867]72
[15110]73    private void aggregationComboBox_SelectedIndexChanged(object sender, EventArgs e) {
74      foreach (var dt in dataTables.Values) {
75        dt.VisualProperties.HistogramAggregation = (DataTableVisualProperties.DataTableHistogramAggregation)aggregationComboBox.SelectedItem;
[12676]76      }
[10818]77    }
[15110]78
79    private void orderComboBox_SelectedIndexChanged(object sender, EventArgs e) {
80      if (Content == null) return;
81
82      Content.Order = (PreprocessingChartContent.LegendOrder)orderComboBox.SelectedItem;
83
84      // rebuild datatables
85      InitData();
86      GenerateLayout();
[12676]87    }
[10658]88  }
89}
Note: See TracBrowser for help on using the repository browser.