Changeset 14459 for branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs
- Timestamp:
- 12/07/16 13:50:21 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs
r14185 r14459 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 23 25 using HeuristicLab.Analysis; 24 26 using HeuristicLab.MainForm; … … 29 31 [Content(typeof(HistogramContent), true)] 30 32 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; } 32 36 33 37 public HistogramView() { 34 38 InitializeComponent(); 35 chartType = DataRowVisualProperties.DataRowChartType.Histogram;36 chartTitle = HISTOGRAM_CHART_TITLE;37 39 } 38 40 … … 53 55 } 54 56 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 55 81 public new HistogramContent Content { 56 82 get { return (HistogramContent)base.Content; } … … 64 90 if (classifierComboBox.SelectedIndex != 0) { 65 91 int columndIndex = Content.PreprocessingData.GetColumnIndex(classifierComboBox.SelectedItem.ToString()); 66 Classification = Content.PreprocessingData.GetValues<double>(columndIndex) ;92 Classification = Content.PreprocessingData.GetValues<double>(columndIndex).ToList(); 67 93 } else { 68 94 Classification = null; … … 70 96 71 97 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(); 85 102 } 86 103 }
Note: See TracChangeset
for help on using the changeset viewer.