Changeset 15239
- Timestamp:
- 07/13/17 17:48:57 (7 years ago)
- Location:
- stable
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 15211,15213,15222
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Views merged: 15211,15213,15222
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/FactorPartialDependencePlot.cs
r15148 r15239 73 73 if (value != yAxisTicks) { 74 74 yAxisTicks = value; 75 SetupAxis(chart .ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax);75 SetupAxis(chart, chart.ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax); 76 76 RecalculateInternalDataset(); 77 77 } … … 84 84 if ((value.HasValue && fixedYAxisMin.HasValue && !value.Value.IsAlmost(fixedYAxisMin.Value)) || (value.HasValue != fixedYAxisMin.HasValue)) { 85 85 fixedYAxisMin = value; 86 SetupAxis(chart .ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax);86 SetupAxis(chart, chart.ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax); 87 87 } 88 88 } … … 94 94 if ((value.HasValue && fixedYAxisMax.HasValue && !value.Value.IsAlmost(fixedYAxisMax.Value)) || (value.HasValue != fixedYAxisMax.HasValue)) { 95 95 fixedYAxisMax = value; 96 SetupAxis(chart .ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax);96 SetupAxis(chart, chart.ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax); 97 97 } 98 98 } … … 209 209 try { 210 210 var limits = await UpdateAllSeriesDataAsync(cancellationToken); 211 chart.Invalidate(); 211 212 212 213 yMin = limits.Lower; … … 214 215 // Set y-axis 215 216 if (resetYAxis) 216 SetupAxis(chart .ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax);217 SetupAxis(chart, chart.ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax); 217 218 218 219 calculationPendingTimer.Stop(); … … 220 221 if (updateOnFinish) 221 222 Update(); 222 } catch (OperationCanceledException) { } catch (AggregateException ae) { 223 } 224 catch (OperationCanceledException) { } 225 catch (AggregateException ae) { 223 226 if (!ae.InnerExceptions.Any(e => e is OperationCanceledException)) 224 227 throw; … … 235 238 } 236 239 237 private void SetupAxis(Axis axis, double minValue, double maxValue, int ticks, double? fixedAxisMin, double? fixedAxisMax) {238 if (minValue < maxValue) {239 double axisMin, axisMax, axisInterval;240 ChartUtil.CalculateAxisInterval(minValue, maxValue, ticks, out axisMin, out axisMax, out axisInterval);241 axis.Minimum = fixedAxisMin ?? axisMin;242 axis.Maximum = fixedAxisMax ?? axisMax;243 axis.Interval = (axis.Maximum - axis.Minimum) / ticks; 244 }245 246 try {247 chart.ChartAreas[0].RecalculateAxesScale();248 } catch (InvalidOperationException) {249 // Can occur if eg. axis min == axis max 250 }240 private static void SetupAxis(EnhancedChart chart, Axis axis, double minValue, double maxValue, int ticks, double? fixedAxisMin, double? fixedAxisMax) { 241 //guard if only one distinct value is present 242 if (minValue.IsAlmost(maxValue)) { 243 minValue = minValue - 0.5; 244 maxValue = minValue + 0.5; 245 } 246 247 double axisMin, axisMax, axisInterval; 248 ChartUtil.CalculateAxisInterval(minValue, maxValue, ticks, out axisMin, out axisMax, out axisInterval); 249 axis.Minimum = fixedAxisMin ?? axisMin; 250 axis.Maximum = fixedAxisMax ?? axisMax; 251 axis.Interval = (axis.Maximum - axis.Minimum) / ticks; 252 253 chart.ChartAreas[0].RecalculateAxesScale(); 251 254 } 252 255 … … 343 346 if (yvalues[i] > max) max = yvalues[i]; 344 347 } 345 chart.Invalidate();346 348 347 349 cancellationToken.ThrowIfCancellationRequested(); … … 358 360 if (upper > max) max = upper; 359 361 } 360 chart.Invalidate();361 362 } 362 363 -
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/PartialDependencePlot.cs
r15137 r15239 82 82 if (value != xAxisTicks) { 83 83 xAxisTicks = value; 84 SetupAxis(chart .ChartAreas[0].AxisX, trainingMin, trainingMax, XAxisTicks, FixedXAxisMin, FixedXAxisMax);84 SetupAxis(chart, chart.ChartAreas[0].AxisX, trainingMin, trainingMax, XAxisTicks, FixedXAxisMin, FixedXAxisMax); 85 85 RecalculateInternalDataset(); 86 86 } … … 93 93 if ((value.HasValue && fixedXAxisMin.HasValue && !value.Value.IsAlmost(fixedXAxisMin.Value)) || (value.HasValue != fixedXAxisMin.HasValue)) { 94 94 fixedXAxisMin = value; 95 if (trainingMin < trainingMax) { 96 SetupAxis(chart.ChartAreas[0].AxisX, trainingMin, trainingMax, XAxisTicks, FixedXAxisMin, FixedXAxisMax); 97 RecalculateInternalDataset(); 98 // set the vertical line position 99 if (VerticalLineAnnotation.X <= fixedXAxisMin) { 100 var axisX = chart.ChartAreas[0].AxisX; 101 var step = (axisX.Maximum - axisX.Minimum) / drawingSteps; 102 VerticalLineAnnotation.X = axisX.Minimum + step; 103 } 95 SetupAxis(chart, chart.ChartAreas[0].AxisX, trainingMin, trainingMax, XAxisTicks, FixedXAxisMin, FixedXAxisMax); 96 RecalculateInternalDataset(); 97 // set the vertical line position 98 if (VerticalLineAnnotation.X <= fixedXAxisMin) { 99 var axisX = chart.ChartAreas[0].AxisX; 100 var step = (axisX.Maximum - axisX.Minimum) / drawingSteps; 101 VerticalLineAnnotation.X = axisX.Minimum + step; 104 102 } 105 103 } … … 112 110 if ((value.HasValue && fixedXAxisMax.HasValue && !value.Value.IsAlmost(fixedXAxisMax.Value)) || (value.HasValue != fixedXAxisMax.HasValue)) { 113 111 fixedXAxisMax = value; 114 if (trainingMin < trainingMax) { 115 SetupAxis(chart.ChartAreas[0].AxisX, trainingMin, trainingMax, XAxisTicks, FixedXAxisMin, FixedXAxisMax); 116 RecalculateInternalDataset(); 117 // set the vertical line position 118 if (VerticalLineAnnotation.X >= fixedXAxisMax) { 119 var axisX = chart.ChartAreas[0].AxisX; 120 var step = (axisX.Maximum - axisX.Minimum) / drawingSteps; 121 VerticalLineAnnotation.X = axisX.Maximum - step; 122 } 112 SetupAxis(chart, chart.ChartAreas[0].AxisX, trainingMin, trainingMax, XAxisTicks, FixedXAxisMin, FixedXAxisMax); 113 RecalculateInternalDataset(); 114 // set the vertical line position 115 if (VerticalLineAnnotation.X >= fixedXAxisMax) { 116 var axisX = chart.ChartAreas[0].AxisX; 117 var step = (axisX.Maximum - axisX.Minimum) / drawingSteps; 118 VerticalLineAnnotation.X = axisX.Maximum - step; 123 119 } 124 120 } … … 132 128 if (value != yAxisTicks) { 133 129 yAxisTicks = value; 134 SetupAxis(chart .ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax);130 SetupAxis(chart, chart.ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax); 135 131 RecalculateInternalDataset(); 136 132 } … … 143 139 if ((value.HasValue && fixedYAxisMin.HasValue && !value.Value.IsAlmost(fixedYAxisMin.Value)) || (value.HasValue != fixedYAxisMin.HasValue)) { 144 140 fixedYAxisMin = value; 145 SetupAxis(chart .ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax);141 SetupAxis(chart, chart.ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax); 146 142 } 147 143 } … … 153 149 if ((value.HasValue && fixedYAxisMax.HasValue && !value.Value.IsAlmost(fixedYAxisMax.Value)) || (value.HasValue != fixedYAxisMax.HasValue)) { 154 150 fixedYAxisMax = value; 155 SetupAxis(chart .ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax);156 } 157 } 158 } 159 160 private double trainingMin = 1;161 private double trainingMax = -1;151 SetupAxis(chart, chart.ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax); 152 } 153 } 154 } 155 156 private double trainingMin = -1; 157 private double trainingMax = 1; 162 158 163 159 private int drawingSteps = 1000; … … 293 289 if (IsDisposed 294 290 || sharedFixedVariables == null || !solutions.Any() || string.IsNullOrEmpty(freeVariable) 295 || trainingMin .IsAlmost(trainingMax) || trainingMin> trainingMax || drawingSteps == 0)291 || trainingMin > trainingMax || drawingSteps == 0) 296 292 return; 297 293 … … 307 303 try { 308 304 var limits = await UpdateAllSeriesDataAsync(cancellationToken); 305 chart.Invalidate(); 309 306 310 307 yMin = limits.Lower; … … 312 309 // Set y-axis 313 310 if (resetYAxis) 314 SetupAxis(chart .ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax);311 SetupAxis(chart, chart.ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax); 315 312 316 313 UpdateOutOfTrainingRangeStripLines(); … … 320 317 if (updateOnFinish) 321 318 Update(); 322 } catch (OperationCanceledException) { } catch (AggregateException ae) { 319 } 320 catch (OperationCanceledException) { } 321 catch (AggregateException ae) { 323 322 if (!ae.InnerExceptions.Any(e => e is OperationCanceledException)) 324 323 throw; … … 335 334 } 336 335 337 private void SetupAxis(Axis axis, double minValue, double maxValue, int ticks, double? fixedAxisMin, double? fixedAxisMax) {338 if (minValue < maxValue) {339 double axisMin, axisMax, axisInterval;340 ChartUtil.CalculateAxisInterval(minValue, maxValue, ticks, out axisMin, out axisMax, out axisInterval);341 axis.Minimum = fixedAxisMin ?? axisMin;342 axis.Maximum = fixedAxisMax ?? axisMax;343 axis.Interval = (axis.Maximum - axis.Minimum) / ticks; 344 }345 346 try {347 chart.ChartAreas[0].RecalculateAxesScale();348 } catch (InvalidOperationException) {349 // Can occur if eg. axis min == axis max 350 }336 private static void SetupAxis(EnhancedChart chart, Axis axis, double minValue, double maxValue, int ticks, double? fixedAxisMin, double? fixedAxisMax) { 337 //guard if only one distinct value is present 338 if (minValue.IsAlmost(maxValue)) { 339 minValue = minValue - 0.5; 340 maxValue = minValue + 0.5; 341 } 342 343 double axisMin, axisMax, axisInterval; 344 ChartUtil.CalculateAxisInterval(minValue, maxValue, ticks, out axisMin, out axisMax, out axisInterval); 345 axis.Minimum = fixedAxisMin ?? axisMin; 346 axis.Maximum = fixedAxisMax ?? axisMax; 347 axis.Interval = (axis.Maximum - axis.Minimum) / ticks; 348 349 chart.ChartAreas[0].RecalculateAxesScale(); 351 350 } 352 351 … … 357 356 if (initializeAxisRanges) { 358 357 double xmin, xmax, xinterval; 359 ChartUtil.CalculateAxisInterval(trainingMin, trainingMax, XAxisTicks, out xmin, out xmax, out xinterval); 358 //guard if only one distinct value is present 359 if (trainingMin.IsAlmost(trainingMax)) 360 ChartUtil.CalculateAxisInterval(trainingMin - 0.5, trainingMax + 0.5, XAxisTicks, out xmin, out xmax, out xinterval); 361 else 362 ChartUtil.CalculateAxisInterval(trainingMin, trainingMax, XAxisTicks, out xmin, out xmax, out xinterval); 363 360 364 FixedXAxisMin = xmin; 361 365 FixedXAxisMax = xmax; … … 369 373 // we expand the range in order to get nice tick intervals on the x axis 370 374 double xmin, xmax, xinterval; 371 ChartUtil.CalculateAxisInterval(trainingMin, trainingMax, XAxisTicks, out xmin, out xmax, out xinterval); 375 //guard if only one distinct value is present 376 if (trainingMin.IsAlmost(trainingMax)) 377 ChartUtil.CalculateAxisInterval(trainingMin - 0.5, trainingMin + 0.5, XAxisTicks, out xmin, out xmax, out xinterval); 378 else 379 ChartUtil.CalculateAxisInterval(trainingMin, trainingMax, XAxisTicks, out xmin, out xmax, out xinterval); 372 380 373 381 if (FixedXAxisMin.HasValue) xmin = FixedXAxisMin.Value; … … 470 478 if (yvalues[i] > max) max = yvalues[i]; 471 479 } 472 chart.Invalidate();473 480 474 481 cancellationToken.ThrowIfCancellationRequested(); … … 485 492 if (upper > max) max = upper; 486 493 } 487 chart.Invalidate();488 494 } 489 495
Note: See TracChangeset
for help on using the changeset viewer.