Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12736


Ignore:
Timestamp:
07/11/15 19:36:04 (9 years ago)
Author:
abeham
Message:

#2274: merged 12614,12670,12679 to stable

Location:
stable
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Analysis.Views

  • stable/HeuristicLab.Analysis.Views/3.3/ScatterPlotView.cs

    r12009 r12736  
    3737    protected List<Series> invisibleSeries;
    3838    protected Dictionary<IObservableList<Point2D<double>>, ScatterPlotDataRow> pointsRowsTable;
     39    private double xMin, xMax, yMin, yMax;
    3940
    4041    public new ScatterPlot Content {
     
    102103        AddScatterPlotDataRows(Content.Rows);
    103104        ConfigureChartArea(chart.ChartAreas[0]);
     105        RecalculateMinMaxPointValues();
    104106        RecalculateAxesScale(chart.ChartAreas[0]);
    105107      }
     
    130132      }
    131133      ConfigureChartArea(chart.ChartAreas[0]);
     134      RecalculateMinMaxPointValues();
    132135      RecalculateAxesScale(chart.ChartAreas[0]);
    133136      UpdateYCursorInterval();
     
    142145          invisibleSeries.Remove(series);
    143146      }
     147      RecalculateMinMaxPointValues();
    144148      RecalculateAxesScale(chart.ChartAreas[0]);
    145149    }
     
    192196
    193197    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;
    200212      area.AxisX.IsMarginVisible = false;
    201213
     
    204216      if (!Content.VisualProperties.YAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.YAxisMinimumFixedValue)) area.AxisY.Minimum = Content.VisualProperties.YAxisMinimumFixedValue;
    205217      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));
    208230    }
    209231
     
    286308        ConfigureSeries(series, row);
    287309        FillSeriesWithRowValues(series, row);
     310        RecalculateMinMaxPointValues();
    288311        RecalculateAxesScale(chart.ChartAreas[0]);
    289312      }
     
    310333            rowSeries.Points.Clear();
    311334            FillSeriesWithRowValues(rowSeries, row);
     335            RecalculateMinMaxPointValues();
    312336            RecalculateAxesScale(chart.ChartAreas[0]);
    313337            UpdateYCursorInterval();
     
    327351            rowSeries.Points.Clear();
    328352            FillSeriesWithRowValues(rowSeries, row);
     353            RecalculateMinMaxPointValues();
    329354            RecalculateAxesScale(chart.ChartAreas[0]);
    330355            UpdateYCursorInterval();
     
    344369            rowSeries.Points.Clear();
    345370            FillSeriesWithRowValues(rowSeries, row);
     371            RecalculateMinMaxPointValues();
    346372            RecalculateAxesScale(chart.ChartAreas[0]);
    347373            UpdateYCursorInterval();
     
    361387            rowSeries.Points.Clear();
    362388            FillSeriesWithRowValues(rowSeries, row);
     389            RecalculateMinMaxPointValues();
    363390            RecalculateAxesScale(chart.ChartAreas[0]);
    364391            UpdateYCursorInterval();
     
    401428        series.Points.Clear();
    402429        invisibleSeries.Add(series);
     430        RecalculateMinMaxPointValues();
    403431      } else {
    404432        invisibleSeries.Remove(series);
     
    409437                     select r).Single();
    410438          FillSeriesWithRowValues(series, row);
     439          RecalculateMinMaxPointValues();
    411440          this.chart.Legends[series.Legend].ForeColor = Color.Black;
    412441          RecalculateAxesScale(chart.ChartAreas[0]);
    413442          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;
    414457        }
    415458      }
  • stable/HeuristicLab.Problems.DataAnalysis.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Clustering/ClusteringSolutionVisualizationView.cs

    r12702 r12736  
    8181
    8282      int idx = 0;
     83      var oneDim = reduced.GetLength(1) == 1;
    8384      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);
    8588        idx++;
    8689      }
     
    106109      alglib.pcabuildbasis(data, instances.Length, attributes.Length, out info, out variances, out matrix);
    107110
    108       var result = new double[instances.Length, 2];
     111      var result = new double[instances.Length, matrix.GetLength(1)];
    109112      int r = 0;
    110113      foreach (var inst in instances) {
Note: See TracChangeset for help on using the changeset viewer.