Changeset 13818 for branches/HeuristicLab.RegressionSolutionGradientView
- Timestamp:
- 05/02/16 12:30:56 (9 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.Designer.cs
r13780 r13818 48 48 series1.Name = "Series1"; 49 49 this.Series.Add(series1); 50 this.AnnotationPositionChanged += new System.EventHandler(this.chart_AnnotationPositionChanged); 50 51 this.AnnotationPositionChanging += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.AnnotationPositionChangingEventArgs>(this.chart_AnnotationPositionChanging); 51 52 this.DragDrop += new System.Windows.Forms.DragEventHandler(this.GradientChart_DragDrop); -
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/GradientChart.cs
r13817 r13818 198 198 if (internalDataset == null || solutionList == null || !solutionList.Any()) 199 199 return; 200 if (min.IsAlmost(max) || min > max) 201 return; 202 if (points == 0) 200 if (min.IsAlmost(max) || min > max || points == 0) 203 201 return; 204 202 Series.Clear(); … … 207 205 Annotations.Clear(); 208 206 Annotations.Add(vla); 207 double axisMin, axisMax, axisInterval; 208 // calculate X-axis interval 209 ChartUtil.CalculateAxisInterval(min, max, 5, out axisMin, out axisMax, out axisInterval); 210 var axis = ChartAreas[0].AxisX; 211 axis.Minimum = axisMin; 212 axis.Maximum = axisMax; 213 axis.Interval = axisInterval; 214 209 215 for (int i = 0; i < solutionList.Count; ++i) { 210 216 var solution = solutionList[i]; … … 214 220 var p = series.Points.Last(); 215 221 vla.X = p.XValue; 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(); 230 AddStripLines(); 222 } 223 // calculate Y-axis interval 224 double ymin = 0, ymax = 0; 225 foreach (var v in Series[0].Points.Select(x => x.YValues[0])) { 226 if (ymin > v) ymin = v; 227 if (ymax < v) ymax = v; 228 } 229 ChartUtil.CalculateAxisInterval(ymin, ymax, 5, out axisMin, out axisMax, out axisInterval); 230 axis = ChartAreas[0].AxisY; 231 axis.Minimum = axisMin; 232 axis.Maximum = axisMax; 233 axis.Interval = axisInterval; 234 ChartAreas[0].AxisX.Title = Variable + " : " + vla.X.ToString("N3", CultureInfo.CurrentCulture); // set axis titlet 235 AddStripLines(); // add strip lines 231 236 if (ShowLegend) 232 237 AddLegends(); … … 311 316 } 312 317 313 private void CalculateAxisInterval() {314 double axisMin, axisMax, axisInterval;315 ChartUtil.CalculateAxisInterval(min, max, 5, out axisMin, out axisMax, out axisInterval);316 var axis = ChartAreas[0].AxisX;317 axis.Minimum = axisMin;318 axis.Maximum = axisMax;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;331 }332 333 318 private void RegisterEvents() { 334 319 AnnotationPositionChanging += chart_AnnotationPositionChanging; … … 352 337 } 353 338 354 // private void chart_AnnotationPositionChanged(object sender, EventArgs e) { 355 // var a = Annotations[0]; 356 // var x = a.X; 357 // var s = Series[0]; 358 // var n = s.Points.Count; 359 // var y = GetEstimatedValue(x); 360 // s.Points[n - 1] = new DataPoint(x, y) { MarkerColor = Color.Red, MarkerSize = 5 }; 361 // a.TextStyle = TextStyle.Default; 362 // Refresh(); 363 // } 339 private void chart_AnnotationPositionChanged(object sender, EventArgs e) { 340 var annotation = VerticalLineAnnotation; 341 var x = annotation.X; 342 internalDataset.SetVariableValue(x, Variable, 0); 343 for (int i = 0; i < solutionList.Count; ++i) { 344 var y = GetEstimatedValue(solutionList[i], x); 345 var s = Series[i]; 346 var n = s.Points.Count; 347 s.Points[n - 1] = new DataPoint(x, y) { MarkerColor = Color.Red, MarkerSize = 5 }; 348 } 349 ChartAreas[0].AxisX.Title = Variable + " : " + x.ToString("N3", CultureInfo.CurrentCulture); 350 Update(); 351 OnVariableValueChanged(this, EventArgs.Empty); 352 } 364 353 365 354 private void chart_AnnotationPositionChanging(object sender, AnnotationPositionChangingEventArgs e) { … … 371 360 if (e.NewLocationX < axisX.Minimum) 372 361 e.NewLocationX = axisX.Minimum; 373 var x = e.NewLocationX;374 internalDataset.SetVariableValue(x, Variable, 0);375 for (int i = 0; i < solutionList.Count; ++i) {376 var y = GetEstimatedValue(solutionList[i], x);377 var s = Series[i];378 var n = s.Points.Count;379 s.Points[n - 1] = new DataPoint(x, y) { MarkerColor = Color.Red, MarkerSize = 5 };380 }381 ChartAreas[0].AxisX.Title = Variable + " : " + x.ToString("N3", CultureInfo.CurrentCulture);382 Update();383 OnVariableValueChanged(this, EventArgs.Empty);362 // var x = e.NewLocationX; 363 // internalDataset.SetVariableValue(x, Variable, 0); 364 // for (int i = 0; i < solutionList.Count; ++i) { 365 // var y = GetEstimatedValue(solutionList[i], x); 366 // var s = Series[i]; 367 // var n = s.Points.Count; 368 // s.Points[n - 1] = new DataPoint(x, y) { MarkerColor = Color.Red, MarkerSize = 5 }; 369 // } 370 // ChartAreas[0].AxisX.Title = Variable + " : " + x.ToString("N3", CultureInfo.CurrentCulture); 371 // Update(); 372 // OnVariableValueChanged(this, EventArgs.Empty); 384 373 } 385 374 -
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/RegressionSolutionTargetResponseGradientView.cs
r13817 r13818 33 33 private ModifiableDataset internalDataset; 34 34 private Dictionary<string, GradientChart> charts; 35 private Dictionary<string, DoubleLimit> variableLimits;36 35 37 36 private const int Points = 1000; … … 75 74 // update charts and variable limits 76 75 charts = new Dictionary<string, GradientChart>(); 77 variableLimits = new Dictionary<string, DoubleLimit>();78 76 foreach (var x in pd.AllowedInputVariables) { 79 77 double min = 0, max = 0; … … 82 80 if (v < min) min = v; 83 81 } 84 variableLimits[x] = new DoubleLimit(min, max);85 82 var gradientChart = new GradientChart { Dock = DockStyle.Fill, ShowLegend = false, Margin = Padding.Empty }; 86 83 gradientChart.VariableValueChanged += (o, e) => {
Note: See TracChangeset
for help on using the changeset viewer.