Changeset 15211 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/FactorPartialDependencePlot.cs
- Timestamp:
- 07/12/17 16:00:13 (6 years ago)
- File:
-
- 1 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 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 } 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
Note: See TracChangeset
for help on using the changeset viewer.