Changeset 14008
- Timestamp:
- 07/06/16 14:50:17 (8 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.cs
r12012 r14008 26 26 using System.Windows.Forms.DataVisualization.Charting; 27 27 using HeuristicLab.MainForm; 28 using HeuristicLab.Visualization.ChartControlsExtensions; 28 29 29 30 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 96 97 this.ToggleSeriesData(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]); 97 98 99 // set the y-axis bounds 100 var axisY = this.chart.ChartAreas[0].AxisY; 101 double min = double.MaxValue, max = double.MinValue; 102 foreach (var point in chart.Series.SelectMany(x => x.Points)) { 103 if (!point.YValues.Any() || double.IsInfinity(point.YValues[0]) || double.IsNaN(point.YValues[0])) 104 continue; 105 var y = point.YValues[0]; 106 if (y < min) 107 min = y; 108 if (y > max) 109 max = y; 110 } 111 112 double axisMin, axisMax, axisInterval; 113 ChartUtil.CalculateOptimalAxisInterval(min, max, out axisMin, out axisMax, out axisInterval); 114 axisY.Minimum = axisMin; 115 axisY.Maximum = axisMax; 116 axisY.Interval = axisInterval; 117 98 118 UpdateCursorInterval(); 99 119 this.UpdateStripLines(); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.cs
r13958 r14008 171 171 172 172 double axisMin, axisMax, axisInterval; 173 ChartUtil.Calculate AxisInterval(min, max, 5, out axisMin, out axisMax, out axisInterval);173 ChartUtil.CalculateOptimalAxisInterval(min, max, out axisMin, out axisMax, out axisInterval); 174 174 this.chart.ChartAreas[0].AxisX.Maximum = axisMax; 175 175 this.chart.ChartAreas[0].AxisX.Minimum = axisMin; -
trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ChartUtil.cs
r14007 r14008 43 43 } 44 44 45 // this method tries to find an axis interval with as few fractional digits as possible (because it looks nicer) 46 // we only try between 3 and 5 ticks (inclusive) because it wouldn't make sense to exceed this interval 47 public static void CalculateOptimalAxisInterval(double min, double max, out double axisMin, out double axisMax, out double axisInterval) { 48 CalculateAxisInterval(min, max, 5, out axisMin, out axisMax, out axisInterval); 49 int bestLsp = int.MaxValue; 50 for (int ticks = 3; ticks <= 5; ++ticks) { 51 double aMin, aMax, aInterval; 52 CalculateAxisInterval(min, max, ticks, out aMin, out aMax, out aInterval); 53 var x = aInterval; 54 int lsp = 0; // position of the least significant fractional digit 55 while (x - Math.Floor(x) > 0) { 56 ++lsp; 57 x *= 10; 58 } 59 if (lsp <= bestLsp) { 60 axisMin = aMin; 61 axisMax = aMax; 62 axisInterval = aInterval; 63 bestLsp = lsp; 64 } 65 } 66 } 67 45 68 private static int Decimals(this double x) { 46 69 if (x.IsAlmost(0) || double.IsInfinity(x) || double.IsNaN(x)) … … 48 71 49 72 var v = Math.Abs(x); 50 int d = 0;73 int d = 1; 51 74 while (v < 1) { 52 75 v *= 10;
Note: See TracChangeset
for help on using the changeset viewer.