Ignore:
Timestamp:
01/04/17 16:33:37 (3 years ago)
Author:
gkronber
Message:

#2650: merged r14504:14533 from trunk to branch

Location:
branches/symbreg-factors-2650
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/symbreg-factors-2650

  • branches/symbreg-factors-2650/HeuristicLab.Analysis.Views

  • branches/symbreg-factors-2650/HeuristicLab.Analysis.Views/3.3/DataTableControl.cs

    r14498 r14542  
    2727using System.Windows.Forms.DataVisualization.Charting;
    2828using HeuristicLab.Collections;
     29using HeuristicLab.MainForm.WindowsForms;
    2930
    3031namespace HeuristicLab.Analysis.Views {
    31   public partial class DataTableControl : UserControl {
     32  public partial class DataTableControl : AsynchronousContentView {
    3233    protected List<Series> invisibleSeries;
    3334    protected Dictionary<IObservableList<double>, DataRow> valuesRowsTable;
    3435
    35     private DataTable content;
    36     public DataTable Content {
    37       get { return content; }
    38       set {
    39         if (value == content) return;
    40         if (content != null) DeregisterContentEvents();
    41         content = value;
    42         if (content != null) RegisterContentEvents();
    43         OnContentChanged();
    44         SetEnabledStateOfControls();
    45       }
     36    public new DataTable Content {
     37      get { return (DataTable)base.Content; }
     38      set { base.Content = value; }
    4639    }
    4740
     
    5649
    5750    #region Event Handler Registration
    58     protected virtual void DeregisterContentEvents() {
     51    protected override void DeregisterContentEvents() {
    5952      foreach (DataRow row in Content.Rows)
    6053        DeregisterDataRowEvents(row);
     
    6558      Content.Rows.CollectionReset -= new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset);
    6659    }
    67     protected virtual void RegisterContentEvents() {
     60    protected override void RegisterContentEvents() {
    6861      Content.VisualPropertiesChanged += new EventHandler(Content_VisualPropertiesChanged);
    6962      Content.Rows.ItemsAdded += new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded);
     
    9588    #endregion
    9689
    97     protected virtual void OnContentChanged() {
     90    protected override void OnContentChanged() {
    9891      invisibleSeries.Clear();
    9992      chart.Titles[0].Text = string.Empty;
     
    111104    }
    112105
    113     protected virtual void SetEnabledStateOfControls() {
     106    protected override void SetEnabledStateOfControls() {
    114107      chart.Enabled = Content != null;
    115108    }
     
    541534      if (!row.Values.Any()) return;
    542535
     536      var validValues = histogramRows.SelectMany(r => r.Values).Where(x => !IsInvalidValue(x)).ToList();
     537      if (!validValues.Any()) return;
     538
    543539      int bins = histogramRows.Max(r => r.VisualProperties.Bins);
    544       decimal minValue = (decimal)histogramRows.Min(r => r.Values.Min());
    545       decimal maxValue = (decimal)histogramRows.Max(r => r.Values.Max());
     540      decimal minValue = (decimal)validValues.Min();
     541      decimal maxValue = (decimal)validValues.Max();
    546542      decimal intervalWidth = (maxValue - minValue) / bins;
    547543      if (intervalWidth < 0) return;
  • branches/symbreg-factors-2650/HeuristicLab.Analysis.Views/3.3/ScatterPlotControl.cs

    r14498 r14542  
    2929using HeuristicLab.Collections;
    3030using HeuristicLab.Common;
     31using HeuristicLab.MainForm.WindowsForms;
    3132
    3233namespace HeuristicLab.Analysis.Views {
    33   public partial class ScatterPlotControl : UserControl {
     34  public partial class ScatterPlotControl : AsynchronousContentView {
    3435    protected List<Series> invisibleSeries;
    3536    protected Dictionary<IObservableList<Point2D<double>>, ScatterPlotDataRow> pointsRowsTable;
     
    3738    private double xMin, xMax, yMin, yMax;
    3839
    39     private ScatterPlot content;
    40     public ScatterPlot Content {
    41       get { return content; }
    42       set {
    43         if (value == content) return;
    44         if (content != null) DeregisterContentEvents();
    45         content = value;
    46         if (content != null) RegisterContentEvents();
    47         OnContentChanged();
    48         SetEnabledStateOfControls();
    49       }
     40    public new ScatterPlot Content {
     41      get { return (ScatterPlot)base.Content; }
     42      set { base.Content = value; }
    5043    }
    5144
     
    6154
    6255    #region Event Handler Registration
    63     protected virtual void DeregisterContentEvents() {
     56    protected override void DeregisterContentEvents() {
    6457      foreach (ScatterPlotDataRow row in Content.Rows)
    6558        DeregisterScatterPlotDataRowEvents(row);
     
    7063      Content.Rows.CollectionReset -= new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_CollectionReset);
    7164    }
    72     protected virtual void RegisterContentEvents() {
     65    protected override void RegisterContentEvents() {
    7366      Content.VisualPropertiesChanged += new EventHandler(Content_VisualPropertiesChanged);
    7467      Content.Rows.ItemsAdded += new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsAdded);
     
    9891    #endregion
    9992
    100     protected virtual void OnContentChanged() {
     93    protected override void OnContentChanged() {
    10194      invisibleSeries.Clear();
    10295      chart.Titles[0].Text = string.Empty;
     
    114107    }
    115108
    116     protected virtual void SetEnabledStateOfControls() {
     109    protected override void SetEnabledStateOfControls() {
    117110      chart.Enabled = Content != null;
    118111    }
     
    508501
    509502    private void FillSeriesWithRowValues(Series series, ScatterPlotDataRow row) {
     503      bool zerosOnly = true;
    510504      for (int i = 0; i < row.Points.Count; i++) {
    511505        var value = row.Points[i];
     
    518512        }
    519513        series.Points.Add(point);
    520       }
     514        if (value.X != 0.0f)
     515          zerosOnly = false;
     516      }
     517      if (zerosOnly) // if all x-values are zero, the x-values are interpreted as 1, 2, 3, ...
     518        series.Points.Add(new DataPoint(1, 1) { IsEmpty = true });
    521519      double correlation = Correlation(row.Points);
    522520      series.LegendToolTip = string.Format("Correlation (R²) = {0:G4}", correlation * correlation);
Note: See TracChangeset for help on using the changeset viewer.