Changeset 12614
- Timestamp:
- 07/06/15 18:00:54 (9 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Analysis.Views/3.3/ScatterPlotView.cs
r12012 r12614 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 } … … 193 197 private void RecalculateAxesScale(ChartArea area) { 194 198 // 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(); 199 area.AxisX.Minimum = CalculateMinBound(xMin); 200 area.AxisX.Maximum = CalculateMaxBound(xMax); 201 area.AxisY.Minimum = CalculateMinBound(yMin); 202 area.AxisY.Maximum = CalculateMaxBound(yMax); 200 203 area.AxisX.IsMarginVisible = false; 201 204 … … 204 207 if (!Content.VisualProperties.YAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.YAxisMinimumFixedValue)) area.AxisY.Minimum = Content.VisualProperties.YAxisMinimumFixedValue; 205 208 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; 209 } 210 211 private static double CalculateMinBound(double min) { 212 double newMin; 213 if (min < 0) { 214 newMin = -Math.Pow(10, Math.Ceiling(Math.Log10(Math.Abs(min)))); 215 if (newMin / 1.25 < min) newMin /= 1.25; 216 if (newMin / 1.6 < min) newMin /= 1.6; 217 if (newMin / 2.5 < min) newMin /= 2.5; 218 if (newMin / 2.0 < min) newMin /= 2.0; 219 } else { 220 newMin = Math.Pow(10, Math.Floor(Math.Log10(min))); 221 if (newMin * 1.25 < min) newMin *= 1.25; 222 if (newMin * 1.6 < min) newMin *= 1.6; 223 if (newMin * 2.5 < min) newMin *= 2.5; 224 if (newMin * 2.0 < min) newMin *= 2.0; 225 } 226 return newMin; 227 } 228 229 private static double CalculateMaxBound(double max) { 230 double newMax; 231 if (max < 0) { 232 newMax = -Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(max)))); 233 if (newMax * 1.25 > max) newMax *= 1.25; 234 if (newMax * 1.6 > max) newMax *= 1.6; 235 if (newMax * 2.5 > max) newMax *= 2.5; 236 if (newMax * 2.0 > max) newMax *= 2.0; 237 } else { 238 newMax = Math.Pow(10, Math.Ceiling(Math.Log10(max))); 239 if (newMax / 1.25 > max) newMax /= 1.25; 240 if (newMax / 1.6 > max) newMax /= 1.6; 241 if (newMax / 2.5 > max) newMax /= 2.5; 242 if (newMax / 2.0 > max) newMax /= 2.0; 243 } 244 return newMax; 208 245 } 209 246 … … 286 323 ConfigureSeries(series, row); 287 324 FillSeriesWithRowValues(series, row); 325 RecalculateMinMaxPointValues(); 288 326 RecalculateAxesScale(chart.ChartAreas[0]); 289 327 } … … 310 348 rowSeries.Points.Clear(); 311 349 FillSeriesWithRowValues(rowSeries, row); 350 RecalculateMinMaxPointValues(); 312 351 RecalculateAxesScale(chart.ChartAreas[0]); 313 352 UpdateYCursorInterval(); … … 327 366 rowSeries.Points.Clear(); 328 367 FillSeriesWithRowValues(rowSeries, row); 368 RecalculateMinMaxPointValues(); 329 369 RecalculateAxesScale(chart.ChartAreas[0]); 330 370 UpdateYCursorInterval(); … … 344 384 rowSeries.Points.Clear(); 345 385 FillSeriesWithRowValues(rowSeries, row); 386 RecalculateMinMaxPointValues(); 346 387 RecalculateAxesScale(chart.ChartAreas[0]); 347 388 UpdateYCursorInterval(); … … 361 402 rowSeries.Points.Clear(); 362 403 FillSeriesWithRowValues(rowSeries, row); 404 RecalculateMinMaxPointValues(); 363 405 RecalculateAxesScale(chart.ChartAreas[0]); 364 406 UpdateYCursorInterval(); … … 401 443 series.Points.Clear(); 402 444 invisibleSeries.Add(series); 445 RecalculateMinMaxPointValues(); 403 446 } else { 404 447 invisibleSeries.Remove(series); … … 409 452 select r).Single(); 410 453 FillSeriesWithRowValues(series, row); 454 RecalculateMinMaxPointValues(); 411 455 this.chart.Legends[series.Legend].ForeColor = Color.Black; 412 456 RecalculateAxesScale(chart.ChartAreas[0]); 413 457 UpdateYCursorInterval(); 458 } 459 } 460 } 461 462 private void RecalculateMinMaxPointValues() { 463 yMin = xMin = double.MaxValue; 464 yMax = xMax = double.MinValue; 465 foreach (var s in chart.Series.Where(x => x.Enabled)) { 466 foreach (var p in s.Points) { 467 double x = p.XValue, y = p.YValues[0]; 468 if (xMin > x) xMin = x; 469 if (xMax < x) xMax = x; 470 if (yMin > y) yMin = y; 471 if (yMax < y) yMax = y; 414 472 } 415 473 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Clustering/ClusteringSolutionVisualizationView.cs
r12509 r12614 81 81 82 82 int idx = 0; 83 var oneDim = reduced.GetLength(1) == 1; 83 84 foreach (var r in range) { 84 rows[classes[r].Item2].Points.Add(new Point2D<double>(reduced[idx, 0], reduced[idx, 1])); 85 Point2D<double> point; 86 point = oneDim ? new Point2D<double>(reduced[idx, 0], 0.0) : new Point2D<double>(reduced[idx, 0], reduced[idx, 1]); 87 rows[classes[r].Item2].Points.Add(point); 85 88 idx++; 86 89 } … … 106 109 alglib.pcabuildbasis(data, instances.Length, attributes.Length, out info, out variances, out matrix); 107 110 108 var result = new double[instances.Length, 2];111 var result = new double[instances.Length, matrix.GetLength(1)]; 109 112 int r = 0; 110 113 foreach (var inst in instances) {
Note: See TracChangeset
for help on using the changeset viewer.