Changeset 15211
 Timestamp:
 07/12/17 16:00:13 (6 years ago)
 Location:
 trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/FactorPartialDependencePlot.cs
r15054 r15211 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 yaxis 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 } 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; 245 252 246 253 try { 247 254 chart.ChartAreas[0].RecalculateAxesScale(); 248 } catch (InvalidOperationException) { 255 } 256 catch (InvalidOperationException) { 249 257 // Can occur if eg. axis min == axis max 250 258 } … … 343 351 if (yvalues[i] > max) max = yvalues[i]; 344 352 } 345 chart.Invalidate();346 353 347 354 cancellationToken.ThrowIfCancellationRequested(); … … 358 365 if (upper > max) max = upper; 359 366 } 360 chart.Invalidate();361 367 } 362 368 
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/PartialDependencePlot.cs
r14852 r15211 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);151 SetupAxis(chart, chart.ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax); 156 152 } 157 153 } … … 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 yaxis 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 } 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; 345 348 346 349 try { 347 350 chart.ChartAreas[0].RecalculateAxesScale(); 348 } catch (InvalidOperationException) { 351 } 352 catch (InvalidOperationException) { 349 353 // Can occur if eg. axis min == axis max 350 354 } … … 357 361 if (initializeAxisRanges) { 358 362 double xmin, xmax, xinterval; 359 ChartUtil.CalculateAxisInterval(trainingMin, trainingMax, XAxisTicks, out xmin, out xmax, out xinterval); 363 //guard if only one distinct value is present 364 if (trainingMin.IsAlmost(trainingMax)) 365 ChartUtil.CalculateAxisInterval(trainingMin  0.5, trainingMax + 0.5, XAxisTicks, out xmin, out xmax, out xinterval); 366 else 367 ChartUtil.CalculateAxisInterval(trainingMin, trainingMax, XAxisTicks, out xmin, out xmax, out xinterval); 368 360 369 FixedXAxisMin = xmin; 361 370 FixedXAxisMax = xmax; … … 369 378 // we expand the range in order to get nice tick intervals on the x axis 370 379 double xmin, xmax, xinterval; 371 ChartUtil.CalculateAxisInterval(trainingMin, trainingMax, XAxisTicks, out xmin, out xmax, out xinterval); 380 //guard if only one distinct value is present 381 if (trainingMin.IsAlmost(trainingMax)) 382 ChartUtil.CalculateAxisInterval(trainingMin  0.5, trainingMin + 0.5, XAxisTicks, out xmin, out xmax, out xinterval); 383 else 384 ChartUtil.CalculateAxisInterval(trainingMin, trainingMax, XAxisTicks, out xmin, out xmax, out xinterval); 372 385 373 386 if (FixedXAxisMin.HasValue) xmin = FixedXAxisMin.Value; … … 470 483 if (yvalues[i] > max) max = yvalues[i]; 471 484 } 472 chart.Invalidate();473 485 474 486 cancellationToken.ThrowIfCancellationRequested(); … … 485 497 if (upper > max) max = upper; 486 498 } 487 chart.Invalidate();488 499 } 489 500
Note: See TracChangeset
for help on using the changeset viewer.