- Timestamp:
- 07/08/15 15:32:12 (9 years ago)
- Location:
- branches/HiveStatistics/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources
-
branches/HiveStatistics/sources/HeuristicLab.Analysis.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Analysis.Views merged: 12614,12670,12679
- Property svn:mergeinfo changed
-
branches/HiveStatistics/sources/HeuristicLab.Analysis.Views/3.3/ScatterPlotView.cs
r12012 r12689 37 37 protected List<Series> invisibleSeries; 38 38 protected Dictionary<IObservableList<Point2D<double>>, ScatterPlotDataRow> pointsRowsTable; 39 private double xMin, xMax, yMin, yMax; 39 40 40 41 public new ScatterPlot Content { … … 102 103 AddScatterPlotDataRows(Content.Rows); 103 104 ConfigureChartArea(chart.ChartAreas[0]); 105 RecalculateMinMaxPointValues(); 104 106 RecalculateAxesScale(chart.ChartAreas[0]); 105 107 } … … 130 132 } 131 133 ConfigureChartArea(chart.ChartAreas[0]); 134 RecalculateMinMaxPointValues(); 132 135 RecalculateAxesScale(chart.ChartAreas[0]); 133 136 UpdateYCursorInterval(); … … 142 145 invisibleSeries.Remove(series); 143 146 } 147 RecalculateMinMaxPointValues(); 144 148 RecalculateAxesScale(chart.ChartAreas[0]); 145 149 } … … 192 196 193 197 private void RecalculateAxesScale(ChartArea area) { 194 // Reset the axes bounds so that RecalculateAxesScale() will assign new bounds 195 foreach (Axis a in area.Axes) { 196 a.Minimum = double.NaN; 197 a.Maximum = double.NaN; 198 } 199 area.RecalculateAxesScale(); 198 area.AxisX.Minimum = CalculateMinBound(xMin); 199 area.AxisX.Maximum = CalculateMaxBound(xMax); 200 if (area.AxisX.Minimum == area.AxisX.Maximum) { 201 area.AxisX.Minimum = xMin - 0.5; 202 area.AxisX.Maximum = xMax + 0.5; 203 } 204 area.AxisY.Minimum = CalculateMinBound(yMin); 205 area.AxisY.Maximum = CalculateMaxBound(yMax); 206 if (area.AxisY.Minimum == area.AxisY.Maximum) { 207 area.AxisY.Minimum = yMin - 0.5; 208 area.AxisY.Maximum = yMax + 0.5; 209 } 210 if (xMax - xMin > 0) area.CursorX.Interval = Math.Pow(10, Math.Floor(Math.Log10(area.AxisX.Maximum - area.AxisX.Minimum) - 3)); 211 else area.CursorX.Interval = 1; 200 212 area.AxisX.IsMarginVisible = false; 201 213 … … 204 216 if (!Content.VisualProperties.YAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.YAxisMinimumFixedValue)) area.AxisY.Minimum = Content.VisualProperties.YAxisMinimumFixedValue; 205 217 if (!Content.VisualProperties.YAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.YAxisMaximumFixedValue)) area.AxisY.Maximum = Content.VisualProperties.YAxisMaximumFixedValue; 206 if (area.AxisX.Minimum >= area.AxisX.Maximum) area.AxisX.Maximum = area.AxisX.Minimum + 1; 207 if (area.AxisY.Minimum >= area.AxisY.Maximum) area.AxisY.Maximum = area.AxisY.Minimum + 1; 218 } 219 220 private static double CalculateMinBound(double min) { 221 if (min == 0) return 0; 222 var scale = Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(min)))); 223 return scale * (Math.Floor(min / scale)); 224 } 225 226 private static double CalculateMaxBound(double max) { 227 if (max == 0) return 0; 228 var scale = Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(max)))); 229 return scale * (Math.Ceiling(max / scale)); 208 230 } 209 231 … … 286 308 ConfigureSeries(series, row); 287 309 FillSeriesWithRowValues(series, row); 310 RecalculateMinMaxPointValues(); 288 311 RecalculateAxesScale(chart.ChartAreas[0]); 289 312 } … … 310 333 rowSeries.Points.Clear(); 311 334 FillSeriesWithRowValues(rowSeries, row); 335 RecalculateMinMaxPointValues(); 312 336 RecalculateAxesScale(chart.ChartAreas[0]); 313 337 UpdateYCursorInterval(); … … 327 351 rowSeries.Points.Clear(); 328 352 FillSeriesWithRowValues(rowSeries, row); 353 RecalculateMinMaxPointValues(); 329 354 RecalculateAxesScale(chart.ChartAreas[0]); 330 355 UpdateYCursorInterval(); … … 344 369 rowSeries.Points.Clear(); 345 370 FillSeriesWithRowValues(rowSeries, row); 371 RecalculateMinMaxPointValues(); 346 372 RecalculateAxesScale(chart.ChartAreas[0]); 347 373 UpdateYCursorInterval(); … … 361 387 rowSeries.Points.Clear(); 362 388 FillSeriesWithRowValues(rowSeries, row); 389 RecalculateMinMaxPointValues(); 363 390 RecalculateAxesScale(chart.ChartAreas[0]); 364 391 UpdateYCursorInterval(); … … 401 428 series.Points.Clear(); 402 429 invisibleSeries.Add(series); 430 RecalculateMinMaxPointValues(); 403 431 } else { 404 432 invisibleSeries.Remove(series); … … 409 437 select r).Single(); 410 438 FillSeriesWithRowValues(series, row); 439 RecalculateMinMaxPointValues(); 411 440 this.chart.Legends[series.Legend].ForeColor = Color.Black; 412 441 RecalculateAxesScale(chart.ChartAreas[0]); 413 442 UpdateYCursorInterval(); 443 } 444 } 445 } 446 447 private void RecalculateMinMaxPointValues() { 448 yMin = xMin = double.MaxValue; 449 yMax = xMax = double.MinValue; 450 foreach (var s in chart.Series.Where(x => x.Enabled)) { 451 foreach (var p in s.Points) { 452 double x = p.XValue, y = p.YValues[0]; 453 if (xMin > x) xMin = x; 454 if (xMax < x) xMax = x; 455 if (yMin > y) yMin = y; 456 if (yMax < y) yMax = y; 414 457 } 415 458 }
Note: See TracChangeset
for help on using the changeset viewer.