Changeset 13828
- Timestamp:
- 05/03/16 17:21:44 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/RegressionSolutionTargetResponseGradientView.cs
r13820 r13828 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 31 32 [Content(typeof(IRegressionSolution))] 32 33 public partial class RegressionSolutionTargetResponseGradientView : DataAnalysisSolutionEvaluationView { 33 private ModifiableDataset internalDataset;34 34 private Dictionary<string, GradientChart> charts; 35 36 35 private const int Points = 1000; 37 36 … … 63 62 var pd = Content.ProblemData; 64 63 var ds = pd.Dataset; 65 66 // update variable list 67 variableListView.Items.Clear(); 68 variableListView.Items.AddRange(pd.AllowedInputVariables.Select(x => new ListViewItem(x, 0)).ToArray()); 69 70 // update internal dataset 71 var variableNames = pd.AllowedInputVariables.ToList(); 64 // create dataset 65 var variableNames = Content.GetUsedVariablesForPrediction().ToList(); 72 66 var variableValues = variableNames.Select(x => new List<double> { pd.Dataset.GetDoubleValues(x, pd.TrainingIndices).Median() }); 73 internalDataset = new ModifiableDataset(variableNames, variableValues);74 // update charts and variable limits67 var dataset = new ModifiableDataset(variableNames, variableValues); 68 // create charts 75 69 charts = new Dictionary<string, GradientChart>(); 76 foreach (var x in pd.AllowedInputVariables) {70 foreach (var x in variableNames) { 77 71 double min = 0, max = 0; 78 72 foreach (var v in ds.GetDoubleValues(x, pd.TrainingIndices)) { … … 94 88 } 95 89 }; 96 gradientChart.Configure(new[] { Content }, pd, internalDataset, x, min, max, Points);90 gradientChart.Configure(new[] { Content }, pd, dataset, x, min, max, Points); 97 91 charts[x] = gradientChart; 98 92 } 93 // update variable list 94 variableListView.Items.Clear(); 95 variableListView.Items.AddRange(variableNames.Select(x => new ListViewItem(x, 0)).ToArray()); 96 } 97 // sort chart controls so that they always appear in the same order as in the list view 98 // the gradient chart layout should be suspended before calling this method 99 private void SortControls() { 100 var tl = gradientChartTableLayout; 101 var indices = variableListView.CheckedItems.Cast<ListViewItem>().ToDictionary(checkedItem => checkedItem.Text, checkedItem => checkedItem.Index); 102 var count = tl.Controls.Count; 103 var controls = new GradientChart[count]; 104 for (int i = 0; i < count; ++i) controls[i] = (GradientChart)tl.Controls[i]; 105 Array.Sort(controls, (a, b) => indices[a.Variable].CompareTo(indices[b.Variable])); 106 tl.Controls.Clear(); 107 tl.Controls.AddRange(controls); 99 108 } 100 109 … … 109 118 var rowHeight = 0.8f * columnWidth; 110 119 tl.RowStyles.Clear(); 111 112 120 if (item.Checked) { 113 121 tl.Controls.Add(chart); 114 var index = tl.Controls.Count - 1;115 int rowIndex = index / tl.ColumnCount;116 int columnIndex = index % tl.ColumnCount;117 tl.SetRow(chart, rowIndex);118 tl.SetColumn(chart, columnIndex);119 122 chart.UpdateChart(); 120 tl.RowCount = rowIndex + 1;121 123 } else { 122 124 tl.Controls.Remove(chart); 123 // relayout124 var count = tl.Controls.Count;125 tl.RowCount = count / tl.ColumnCount + (count % tl.ColumnCount == 0 ? 0 : 1);126 for (int i = 0; i < count; ++i) {127 var control = tl.Controls[i];128 int rowIndex = i / tl.ColumnCount;129 int columnIndex = i % tl.ColumnCount;130 tl.SetRow(control, rowIndex);131 tl.SetColumn(control, columnIndex);132 }133 125 } 134 // set absolute row sizes 126 var count = tl.Controls.Count; 127 SortControls(); 128 tl.RowCount = count / tl.ColumnCount + (count % tl.ColumnCount == 0 ? 0 : 1); 129 for (int i = 0; i < count; ++i) { 130 var control = tl.Controls[i]; 131 int rowIndex = i / tl.ColumnCount; 132 int columnIndex = i % tl.ColumnCount; 133 tl.SetRow(control, rowIndex); 134 tl.SetColumn(control, columnIndex); 135 } 135 136 for (int i = 0; i < tl.RowCount; ++i) { 136 137 tl.RowStyles.Add(new RowStyle(SizeType.Absolute, rowHeight));
Note: See TracChangeset
for help on using the changeset viewer.