Changeset 14860


Ignore:
Timestamp:
04/13/17 14:01:44 (2 weeks ago)
Author:
mkommend
Message:

#2765: Implemented tags for data points in ScatterPlot.

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis.Views/3.3/ScatterPlotControl.Designer.cs

    r14826 r14860  
    8787      this.chart.Titles.Add(title1);
    8888      this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend);
     89      this.chart.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDoubleClick);
    8990      this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
    9091      this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
  • trunk/sources/HeuristicLab.Analysis.Views/3.3/ScatterPlotControl.cs

    r14826 r14860  
    2929using HeuristicLab.Collections;
    3030using HeuristicLab.Common;
     31using HeuristicLab.MainForm;
    3132using HeuristicLab.MainForm.WindowsForms;
    3233
     
    122123      foreach (var row in rows) {
    123124        RegisterScatterPlotDataRowEvents(row);
    124         Series series = new Series(row.Name) {
    125           Tag = row
    126         };
     125        Series series = new Series(row.Name) { Tag = row };
     126
    127127        if (row.VisualProperties.DisplayName.Trim() != String.Empty) series.LegendText = row.VisualProperties.DisplayName;
    128128        else series.LegendText = row.Name;
     129
    129130        var regressionSeries = new Series(row.Name + "_Regression") {
    130131          Tag = row,
     
    134135          Color = Color.Transparent // to avoid auto color assignment via color palette
    135136        };
     137
    136138        seriesToRegressionSeriesTable.Add(series, regressionSeries);
    137139        ConfigureSeries(series, regressionSeries, row);
    138140        FillSeriesWithRowValues(series, row);
     141
    139142        chart.Series.Add(series);
    140143        chart.Series.Add(regressionSeries);
     
    439442
    440443    #region Chart Event Handlers
     444    private void chart_MouseDoubleClick(object sender, MouseEventArgs e) {
     445      HitTestResult result = chart.HitTest(e.X, e.Y,ChartElementType.DataPoint);
     446      if (result.ChartElementType != ChartElementType.DataPoint) return;
     447
     448      var series = result.Series;
     449      var dataPoint = series.Points[result.PointIndex];
     450      var tag = dataPoint.Tag;
     451      var content = tag as IContent;
     452
     453      if (tag == null) return;
     454      if (content == null) return;
     455
     456      MainFormManager.MainForm.ShowContent(content);
     457    }
     458
    441459    private void chart_MouseDown(object sender, MouseEventArgs e) {
    442460      HitTestResult result = chart.HitTest(e.X, e.Y);
     
    511529          point.YValues = new double[] { value.Y };
    512530        }
     531        point.Tag = value.Tag;
    513532        series.Points.Add(point);
    514533        if (value.X != 0.0f)
     
    604623      double cov = sxy / n - sx * sy / n / n;
    605624      // standard error of x
    606       double sigmaX = Math.Sqrt(sxx / n -  sx * sx / n / n);
     625      double sigmaX = Math.Sqrt(sxx / n - sx * sx / n / n);
    607626      // standard error of y
    608       double sigmaY = Math.Sqrt(syy / n -  sy * sy / n / n);
     627      double sigmaY = Math.Sqrt(syy / n - sy * sy / n / n);
    609628
    610629      // correlation
  • trunk/sources/HeuristicLab.Common/3.3/Point2D.cs

    r14185 r14860  
    2626namespace HeuristicLab.Common {
    2727  [Serializable]
    28   public struct Point2D<T> where T : struct {
     28  public struct Point2D<T> where T : struct, IEquatable<T> {
    2929    public static readonly Point2D<T> Empty = new Point2D<T>();
    3030
     
    3838    }
    3939
     40    private object tag;
     41    public object Tag {
     42      get { return tag; }
     43    }
     44
    4045    [Browsable(false)]
    4146    public bool IsEmpty {
     
    4348    }
    4449
    45     public Point2D(T x, T y) {
     50    public Point2D(T x, T y, object tag = null) {
    4651      this.x = x;
    4752      this.y = y;
     53      this.tag = tag;
    4854    }
    4955
    5056    public static bool operator ==(Point2D<T> left, Point2D<T> right) {
    51       return left.x.Equals(right.x) && left.y.Equals(right.y);
     57      return left.x.Equals(right.x) && left.y.Equals(right.y) && left.tag == right.tag;
    5258    }
    5359    public static bool operator !=(Point2D<T> left, Point2D<T> right) {
     
    5965        return false;
    6066      Point2D<T> point = (Point2D<T>)obj;
    61       return x.Equals(point.x) && y.Equals(point.y) && GetType().Equals(point.GetType());
     67      return GetType() == point.GetType() && x.Equals(point.x) && y.Equals(point.y) &&
     68             ((tag != null && tag.Equals(point.tag)) || tag == point.tag);
    6269    }
    6370    public override int GetHashCode() {
Note: See TracChangeset for help on using the changeset viewer.