Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/07/16 13:50:21 (7 years ago)
Author:
pfleck
Message:

#2709

  • Removed the PreprocessingDataTable and PreprocessingDataTableView and use dhe HL DatatTableControl instead.
  • Moved and refactored some code of PreprocessingChart and moved unnecessary code from base classes to actual derivative classes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs

    r14185 r14459  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2325using HeuristicLab.Analysis;
    2426using HeuristicLab.MainForm;
     
    2931  [Content(typeof(HistogramContent), true)]
    3032  public partial class HistogramView : PreprocessingChartView {
    31     private const string HISTOGRAM_CHART_TITLE = "Histogram";
     33
     34    public List<double> Classification { get; set; }
     35    public bool IsDetailedChartViewEnabled { get; set; }
    3236
    3337    public HistogramView() {
    3438      InitializeComponent();
    35       chartType = DataRowVisualProperties.DataRowChartType.Histogram;
    36       chartTitle = HISTOGRAM_CHART_TITLE;
    3739    }
    3840
     
    5355    }
    5456
     57    protected override DataTable CreateDataTable(string variableName) {
     58      var dt = new DataTable();
     59      var row = Content.CreateDataRow(variableName, DataRowVisualProperties.DataRowChartType.Histogram);
     60      if (Classification == null) {
     61        dt.Rows.Add(row);
     62      } else {
     63        dt.VisualProperties.Title = variableName;
     64        //var valuesPerClass = row.Values.Zip(Classification, (value, @class) => new { value, @class })
     65        //                        .GroupBy(x => x.@class)
     66        //                        .ToDictionary(x => x.Key, x => x.Select(v => v.value));
     67        var valuesPerClass = row.Values.Select((i, index) => new { i, j = Classification.ToList()[index] })
     68                                       .GroupBy((x) => x.j)
     69                                       .ToDictionary(x => x.Key, x => x.Select(v => v.i)
     70                                       .ToList());
     71        foreach (var entry in valuesPerClass) {
     72          var classRow = new DataRow(entry.Key.ToString());
     73          classRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
     74          classRow.Values.AddRange(entry.Value);
     75          dt.Rows.Add(classRow);
     76        }
     77      }
     78      return dt;
     79    }
     80
    5581    public new HistogramContent Content {
    5682      get { return (HistogramContent)base.Content; }
     
    6490      if (classifierComboBox.SelectedIndex != 0) {
    6591        int columndIndex = Content.PreprocessingData.GetColumnIndex(classifierComboBox.SelectedItem.ToString());
    66         Classification = Content.PreprocessingData.GetValues<double>(columndIndex);
     92        Classification = Content.PreprocessingData.GetValues<double>(columndIndex).ToList();
    6793      } else {
    6894        Classification = null;
     
    7096
    7197      Content.ClassifierVariableIndex = classifierComboBox.SelectedIndex;
    72       if (Content.IsDetailedChartViewEnabled != IsDetailedChartViewEnabled) {
    73         displayDetailsCheckBox.Checked = Content.IsDetailedChartViewEnabled;
    74       } else {
    75         GenerateChart();
    76       }
    77     }
    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();
    84       }
     98
     99      // rebuild datatables
     100      InitData();
     101      GenerateLayout();
    85102    }
    86103  }
Note: See TracChangeset for help on using the changeset viewer.