- Timestamp:
- 04/29/16 17:09:15 (8 years ago)
- Location:
- branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/GradientChart.cs
r13808 r13817 23 23 using System.Collections.Generic; 24 24 using System.Drawing; 25 using System.Globalization; 25 26 using System.Linq; 26 27 using System.Windows.Forms; … … 32 33 public partial class GradientChart : EnhancedChart { 33 34 private ModifiableDataset internalDataset; 35 36 public bool ShowLegend { get; set; } 34 37 35 38 private bool useMedianValues; … … 199 202 if (points == 0) 200 203 return; 201 CalculateAxisInterval();202 204 Series.Clear(); 203 205 var vla = VerticalLineAnnotation; … … 212 214 var p = series.Points.Last(); 213 215 vla.X = p.XValue; 214 var ta = new TextAnnotation { 215 Text = string.Format("X: {0:0.000}, Y: {1:0.000}", p.XValue, p.YValues[0]), 216 Visible = true, 217 X = p.XValue, 218 Y = p.YValues[0], 219 AxisX = ChartAreas[0].AxisX, 220 AxisY = ChartAreas[0].AxisY 221 }; 222 ta.ClipToChartArea = "ChartArea1"; 223 ta.Name = series.Name; 224 Annotations.Add(ta); 225 } 216 ChartAreas[0].AxisX.Title = Variable + " " + vla.X.ToString("N3", CultureInfo.CurrentCulture); 217 // var ta = new TextAnnotation { 218 // Text = string.Format("X: {0:0.000}, Y: {1:0.000}", p.XValue, p.YValues[0]), 219 // Visible = true, 220 // X = p.XValue, 221 // Y = p.YValues[0], 222 // AxisX = ChartAreas[0].AxisX, 223 // AxisY = ChartAreas[0].AxisY 224 // }; 225 // ta.ClipToChartArea = "ChartArea1"; 226 // ta.Name = series.Name; 227 // Annotations.Add(ta); 228 } 229 CalculateAxisInterval(); 226 230 AddStripLines(); 227 AddLegends(); 231 if (ShowLegend) 232 AddLegends(); 228 233 } 229 234 … … 260 265 var step = (max - min) / points; 261 266 var axisX = ChartAreas[0].AxisX; 262 axisX.Title = Variable ;267 axisX.Title = Variable + " : " + v.ToString("N3", CultureInfo.CurrentCulture); 263 268 var axisY = ChartAreas[0].AxisY; 264 269 axisY.Title = Target; … … 290 295 Legends.Clear(); 291 296 var legend = new Legend(); 292 // legend.Name = s.Name;293 297 legend.Alignment = StringAlignment.Center; 294 298 legend.LegendStyle = LegendStyle.Row; … … 302 306 private void AddStripLines() { 303 307 var axisX = ChartAreas[0].AxisX; 304 axisX.Title = Variable;305 var axisY = ChartAreas[0].AxisY;306 axisY.Title = ProblemData.TargetVariable;307 308 axisX.StripLines.Clear(); 308 309 axisX.StripLines.Add(new StripLine { BackColor = Color.FromArgb(30, Color.Green), IntervalOffset = axisX.Minimum, StripWidth = min - axisX.Minimum }); … … 317 318 axis.Maximum = axisMax; 318 319 axis.Interval = axisInterval; 320 321 double ymin = 0, ymax = 0; 322 foreach (var v in Series[0].Points.Select(x => x.YValues[0])) { 323 if (ymin > v) ymin = v; 324 if (ymax < v) ymax = v; 325 } 326 ChartUtil.CalculateAxisInterval(ymin, ymax, 5, out axisMin, out axisMax, out axisInterval); 327 axis = ChartAreas[0].AxisY; 328 axis.Minimum = axisMin; 329 axis.Maximum = axisMax; 330 axis.Interval = axisInterval; 319 331 } 320 332 … … 326 338 327 339 #region events 340 public event EventHandler VariableValueChanged; 341 public void OnVariableValueChanged(object sender, EventArgs args) { 342 var changed = VariableValueChanged; 343 if (changed == null) return; 344 changed(sender, args); 345 } 346 328 347 public event EventHandler ChartPropertyChanged; 329 348 public void OnChartPropertyChanged(object sender, EventArgs args) { … … 353 372 e.NewLocationX = axisX.Minimum; 354 373 var x = e.NewLocationX; 355 356 // var va = VerticalLineAnnotation; 357 // Annotations.Clear(); 358 // Annotations.Add(va); 374 internalDataset.SetVariableValue(x, Variable, 0); 359 375 for (int i = 0; i < solutionList.Count; ++i) { 360 376 var y = GetEstimatedValue(solutionList[i], x); … … 363 379 s.Points[n - 1] = new DataPoint(x, y) { MarkerColor = Color.Red, MarkerSize = 5 }; 364 380 } 365 foreach (var annotation in Annotations.OfType<TextAnnotation>()) { 366 var p = Series[annotation.Name].Points.Last(); 367 annotation.Text = string.Format("X: {0:0.000}, Y: {1:0.000}", p.XValue, p.YValues[0]); 368 annotation.X = p.XValue; 369 annotation.Y = p.YValues[0]; 370 } 381 ChartAreas[0].AxisX.Title = Variable + " : " + x.ToString("N3", CultureInfo.CurrentCulture); 371 382 Update(); 383 OnVariableValueChanged(this, EventArgs.Empty); 372 384 } 373 385 … … 390 402 } 391 403 } 392 #endregion393 404 394 405 private void GradientChart_DragDrop(object sender, DragEventArgs e) { … … 411 422 } 412 423 } 424 #endregion 413 425 } 414 426 } -
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/RegressionSolutionTargetResponseGradientView.Designer.cs
r13808 r13817 25 25 private void InitializeComponent() { 26 26 this.variableListView = new System.Windows.Forms.ListView(); 27 this.panel1 = new System.Windows.Forms.Panel(); 27 28 this.gradientChartTableLayout = new System.Windows.Forms.TableLayoutPanel(); 29 this.panel1.SuspendLayout(); 28 30 this.SuspendLayout(); 29 31 // … … 35 37 this.variableListView.Location = new System.Drawing.Point(4, 4); 36 38 this.variableListView.Name = "variableListView"; 37 this.variableListView.Size = new System.Drawing.Size( 263, 944);39 this.variableListView.Size = new System.Drawing.Size(152, 332); 38 40 this.variableListView.TabIndex = 0; 39 41 this.variableListView.UseCompatibleStateImageBehavior = false; 40 42 this.variableListView.View = System.Windows.Forms.View.List; 41 43 // 44 // panel1 45 // 46 this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 47 | System.Windows.Forms.AnchorStyles.Left) 48 | System.Windows.Forms.AnchorStyles.Right))); 49 this.panel1.AutoScroll = true; 50 this.panel1.Controls.Add(this.gradientChartTableLayout); 51 this.panel1.Location = new System.Drawing.Point(162, 4); 52 this.panel1.Name = "panel1"; 53 this.panel1.Size = new System.Drawing.Size(868, 693); 54 this.panel1.TabIndex = 1; 55 // 42 56 // gradientChartTableLayout 43 57 // 44 this.gradientChartTableLayout.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 45 | System.Windows.Forms.AnchorStyles.Left) 58 this.gradientChartTableLayout.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 46 59 | System.Windows.Forms.AnchorStyles.Right))); 47 this.gradientChartTableLayout.ColumnCount = 2; 48 this.gradientChartTableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 49 this.gradientChartTableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 50 this.gradientChartTableLayout.Location = new System.Drawing.Point(274, 4); 60 this.gradientChartTableLayout.AutoSize = true; 61 this.gradientChartTableLayout.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 62 this.gradientChartTableLayout.ColumnCount = 4; 63 this.gradientChartTableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); 64 this.gradientChartTableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); 65 this.gradientChartTableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); 66 this.gradientChartTableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); 67 this.gradientChartTableLayout.Location = new System.Drawing.Point(3, 3); 51 68 this.gradientChartTableLayout.Name = "gradientChartTableLayout"; 52 this.gradientChartTableLayout.RowCount = 2; 53 this.gradientChartTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); 54 this.gradientChartTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); 55 this.gradientChartTableLayout.Size = new System.Drawing.Size(1323, 944); 56 this.gradientChartTableLayout.TabIndex = 1; 69 this.gradientChartTableLayout.RowCount = 1; 70 this.gradientChartTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 693F)); 71 this.gradientChartTableLayout.Size = new System.Drawing.Size(848, 693); 72 this.gradientChartTableLayout.TabIndex = 2; 57 73 // 58 74 // RegressionSolutionTargetResponseGradientView … … 60 76 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 61 77 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 62 this.Controls.Add(this. gradientChartTableLayout);78 this.Controls.Add(this.panel1); 63 79 this.Controls.Add(this.variableListView); 64 80 this.Name = "RegressionSolutionTargetResponseGradientView"; 65 this.Size = new System.Drawing.Size(1600, 951); 81 this.Size = new System.Drawing.Size(1033, 700); 82 this.panel1.ResumeLayout(false); 83 this.panel1.PerformLayout(); 66 84 this.ResumeLayout(false); 67 85 … … 71 89 72 90 private System.Windows.Forms.ListView variableListView; 91 private System.Windows.Forms.Panel panel1; 73 92 private System.Windows.Forms.TableLayoutPanel gradientChartTableLayout; 74 93 } -
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/RegressionSolutionTargetResponseGradientView.cs
r13808 r13817 1 using System.Collections.Generic; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 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 */ 20 #endregion 21 22 using System.Collections.Generic; 2 23 using System.Linq; 3 24 using System.Windows.Forms; 4 25 using HeuristicLab.Common; 5 26 using HeuristicLab.MainForm; 27 using HeuristicLab.MainForm.WindowsForms; 6 28 7 29 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 39 61 protected override void OnContentChanged() { 40 62 base.OnContentChanged(); 63 if (Content == null) return; 41 64 var pd = Content.ProblemData; 42 65 var ds = pd.Dataset; … … 50 73 var variableValues = variableNames.Select(x => new List<double> { pd.Dataset.GetDoubleValues(x, pd.TrainingIndices).Median() }); 51 74 internalDataset = new ModifiableDataset(variableNames, variableValues); 52 53 75 // update charts and variable limits 54 76 charts = new Dictionary<string, GradientChart>(); … … 61 83 } 62 84 variableLimits[x] = new DoubleLimit(min, max); 63 var gradientChart = new GradientChart(); 85 var gradientChart = new GradientChart { Dock = DockStyle.Fill, ShowLegend = false, Margin = Padding.Empty }; 86 gradientChart.VariableValueChanged += (o, e) => { 87 foreach (var chart in gradientChartTableLayout.Controls.Cast<GradientChart>()) { 88 if (chart == (GradientChart)o) continue; 89 chart.UpdateChart(); 90 } 91 }; 64 92 gradientChart.Configure(new[] { Content }, pd, internalDataset, x, min, max, Points); 65 93 charts[x] = gradientChart; … … 72 100 var variable = item.Text; 73 101 var chart = charts[variable]; 102 var tl = gradientChartTableLayout; 103 tl.SuspendLayout(); 104 var columnWidth = tl.GetColumnWidths()[0]; // all columns have the same width 105 var rowHeight = 0.8f * columnWidth; 106 tl.RowStyles.Clear(); 107 74 108 if (item.Checked) { 75 gradientChartTableLayout.Controls.Add(chart); 109 tl.Controls.Add(chart); 110 var index = tl.Controls.Count - 1; 111 int rowIndex = index / tl.ColumnCount; 112 int columnIndex = index % tl.ColumnCount; 113 tl.SetRow(chart, rowIndex); 114 tl.SetColumn(chart, columnIndex); 76 115 chart.UpdateChart(); 116 tl.RowCount = rowIndex + 1; 77 117 } else { 78 gradientChartTableLayout.Controls.Remove(chart); 118 tl.Controls.Remove(chart); 119 // relayout 120 var count = tl.Controls.Count; 121 tl.RowCount = count / tl.ColumnCount + (count % tl.ColumnCount == 0 ? 0 : 1); 122 for (int i = 0; i < count; ++i) { 123 var control = tl.Controls[i]; 124 int rowIndex = i / tl.ColumnCount; 125 int columnIndex = i % tl.ColumnCount; 126 tl.SetRow(control, rowIndex); 127 tl.SetColumn(control, columnIndex); 128 } 79 129 } 130 // set absolute row sizes 131 for (int i = 0; i < tl.RowCount; ++i) { 132 tl.RowStyles.Add(new RowStyle(SizeType.Absolute, rowHeight)); 133 } 134 tl.ResumeLayout(); 80 135 } 81 136 }
Note: See TracChangeset
for help on using the changeset viewer.