Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/14/17 10:29:51 (7 years ago)
Author:
pfleck
Message:

#2709 merged to stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.DataPreprocessing.Views

  • stable/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs

    r14186 r15242  
    2121
    2222using System;
     23using System.Drawing;
    2324using HeuristicLab.Analysis;
    2425using HeuristicLab.MainForm;
    2526
    2627namespace HeuristicLab.DataPreprocessing.Views {
    27 
    2828  [View("Histogram View")]
    2929  [Content(typeof(HistogramContent), true)]
    3030  public partial class HistogramView : PreprocessingChartView {
    31     private const string HISTOGRAM_CHART_TITLE = "Histogram";
    32 
    33     public HistogramView() {
    34       InitializeComponent();
    35       chartType = DataRowVisualProperties.DataRowChartType.Histogram;
    36       chartTitle = HISTOGRAM_CHART_TITLE;
    37     }
    38 
    39     protected override void OnContentChanged() {
    40       base.OnContentChanged();
    41       if (Content != null) {
    42         classifierComboBox.Items.Clear();
    43         classifierComboBox.Items.Add("None");
    44 
    45         foreach (string var in Content.GetVariableNamesForHistogramClassification()) {
    46           classifierComboBox.Items.Add(var);
    47         }
    48 
    49         if (classifierComboBox.SelectedItem == null && Content.ClassifierVariableIndex < classifierComboBox.Items.Count) {
    50           classifierComboBox.SelectedIndex = Content.ClassifierVariableIndex;
    51         }
    52       }
    53     }
    54 
    5531    public new HistogramContent Content {
    5632      get { return (HistogramContent)base.Content; }
     
    5834    }
    5935
    60     private void classifierComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    61       if (classifierComboBox.SelectedItem == null)
    62         return;
     36    public HistogramView() {
     37      InitializeComponent();
     38      aggregationComboBox.DataSource = Enum.GetValues(typeof(DataTableVisualProperties.DataTableHistogramAggregation));
     39      aggregationComboBox.SelectedItem = DataTableVisualProperties.DataTableHistogramAggregation.Overlapping;
     40      orderComboBox.DataSource = Enum.GetValues(typeof(PreprocessingChartContent.LegendOrder));
     41      orderComboBox.SelectedItem = PreprocessingChartContent.LegendOrder.Alphabetically;
     42    }
    6343
    64       if (classifierComboBox.SelectedIndex != 0) {
    65         int columndIndex = Content.PreprocessingData.GetColumnIndex(classifierComboBox.SelectedItem.ToString());
    66         Classification = Content.PreprocessingData.GetValues<double>(columndIndex);
    67       } else {
    68         Classification = null;
    69       }
     44    protected override void OnContentChanged() {
     45      base.OnContentChanged();
     46      groupingComboBox.Items.Clear();
     47      groupingComboBox.Items.Add(string.Empty);
    7048
    71       Content.ClassifierVariableIndex = classifierComboBox.SelectedIndex;
    72       if (Content.IsDetailedChartViewEnabled != IsDetailedChartViewEnabled) {
    73         displayDetailsCheckBox.Checked = Content.IsDetailedChartViewEnabled;
    74       } else {
    75         GenerateChart();
     49      if (Content != null) {
     50        foreach (string var in PreprocessingChartContent.GetVariableNamesForGrouping(Content.PreprocessingData)) {
     51          groupingComboBox.Items.Add(var);
     52        }
     53
     54        groupingComboBox.SelectedItem = Content.GroupingVariableName ?? string.Empty;
    7655      }
    7756    }
    78     private void displayDetailsCheckBox_CheckedChanged(object sender, EventArgs e) {
    79       bool isChecked = displayDetailsCheckBox.Checked;
    80       if (IsDetailedChartViewEnabled != isChecked) {
    81         IsDetailedChartViewEnabled = isChecked;
    82         Content.IsDetailedChartViewEnabled = isChecked;
    83         GenerateChart();
     57
     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;
     63    }
     64
     65    private void classifierComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     66      Content.GroupingVariableName = groupingComboBox.SelectedItem.ToString();
     67
     68      // rebuild datatables
     69      InitData();
     70      GenerateLayout();
     71    }
     72
     73    private void aggregationComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     74      foreach (var dt in dataTables.Values) {
     75        dt.VisualProperties.HistogramAggregation = (DataTableVisualProperties.DataTableHistogramAggregation)aggregationComboBox.SelectedItem;
    8476      }
     77    }
     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();
    8587    }
    8688  }
Note: See TracChangeset for help on using the changeset viewer.