Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs @ 15027

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

#2709 Fixed an issue with empty charts.

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;
[15021]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 {
[14579]31    public new HistogramContent Content {
32      get { return (HistogramContent)base.Content; }
33      set { base.Content = value; }
34    }
[10658]35
36    public HistogramView() {
37      InitializeComponent();
[14583]38      aggregationComboBox.DataSource = Enum.GetValues(typeof(DataRowVisualProperties.DataRowHistogramAggregation));
39      aggregationComboBox.SelectedItem = DataRowVisualProperties.DataRowHistogramAggregation.Overlapping;
[14993]40      orderComboBox.DataSource = Enum.GetValues(typeof(PreprocessingChartContent.LegendOrder));
41      orderComboBox.SelectedItem = PreprocessingChartContent.LegendOrder.Appearance;
[10658]42    }
43
[10914]44    protected override void OnContentChanged() {
[10867]45      base.OnContentChanged();
[14996]46      groupingComboBox.Items.Clear();
47      groupingComboBox.Items.Add(string.Empty);
[14579]48
[10914]49      if (Content != null) {
[14725]50        foreach (string var in PreprocessingChartContent.GetVariableNamesForGrouping(Content.PreprocessingData)) {
[14996]51          groupingComboBox.Items.Add(var);
[10867]52        }
53
[14996]54        groupingComboBox.SelectedItem = Content.GroupingVariableName ?? string.Empty;
[10867]55      }
56    }
57
[14459]58    protected override DataTable CreateDataTable(string variableName) {
[14725]59      var aggregation = (DataRowVisualProperties.DataRowHistogramAggregation)aggregationComboBox.SelectedItem;
[15021]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;
[14579]63    }
64
65    private void classifierComboBox_SelectedIndexChanged(object sender, EventArgs e) {
[14996]66      Content.GroupingVariableName = groupingComboBox.SelectedItem.ToString();
[14579]67
[14459]68      // rebuild datatables
69      InitData();
70      GenerateLayout();
[10818]71    }
[14583]72
73    private void aggregationComboBox_SelectedIndexChanged(object sender, EventArgs e) {
74      foreach (var dt in dataTables.Values) {
75        foreach (var row in dt.Rows) {
76          row.VisualProperties.Aggregation = (DataRowVisualProperties.DataRowHistogramAggregation)aggregationComboBox.SelectedItem;
77        }
78      }
79    }
[14993]80
81    private void orderComboBox_SelectedIndexChanged(object sender, EventArgs e) {
[15027]82      if (Content == null) return;
83
[14993]84      Content.Order = (PreprocessingChartContent.LegendOrder)orderComboBox.SelectedItem;
85
86      // rebuild datatables
87      InitData();
88      GenerateLayout();
89    }
[10658]90  }
91}
Note: See TracBrowser for help on using the repository browser.