Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12884 for branches


Ignore:
Timestamp:
08/19/15 13:59:32 (9 years ago)
Author:
pfleck
Message:

#2379
Added tooltip when hovering a data point.
Click on a data point opens the corresponding DataItem or both if x and y values came from different DataItems.

Location:
branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3/BubbleChartView.Designer.cs

    r12882 r12884  
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
    48       System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
    49       System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
     48      System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
     49      System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
    5050      this.yLabel = new System.Windows.Forms.Label();
    5151      this.xLabel = new System.Windows.Forms.Label();
     
    5656      this.childrenGroupBox = new System.Windows.Forms.GroupBox();
    5757      this.splitContainer = new System.Windows.Forms.SplitContainer();
     58      this.noDataLabel = new System.Windows.Forms.Label();
    5859      this.sizeComboBox = new System.Windows.Forms.ComboBox();
    5960      this.sizeLabel = new System.Windows.Forms.Label();
     
    6667      this.yJitterTrackBar = new System.Windows.Forms.TrackBar();
    6768      this.xJitterTrackBar = new System.Windows.Forms.TrackBar();
    68       this.noDataLabel = new System.Windows.Forms.Label();
     69      this.tooltip = new System.Windows.Forms.ToolTip(this.components);
    6970      ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
    7071      this.childrenGroupBox.SuspendLayout();
     
    103104            | System.Windows.Forms.AnchorStyles.Left)
    104105            | System.Windows.Forms.AnchorStyles.Right)));
    105       chartArea2.Name = "ChartArea1";
    106       this.chart.ChartAreas.Add(chartArea2);
     106      chartArea1.Name = "ChartArea1";
     107      this.chart.ChartAreas.Add(chartArea1);
    107108      this.chart.Location = new System.Drawing.Point(3, 3);
    108109      this.chart.Name = "chart";
    109       series2.ChartArea = "ChartArea1";
    110       series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
    111       series2.IsVisibleInLegend = false;
    112       series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
    113       series2.Name = "Bubbles";
    114       series2.YValuesPerPoint = 2;
    115       this.chart.Series.Add(series2);
     110      series1.ChartArea = "ChartArea1";
     111      series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
     112      series1.IsVisibleInLegend = false;
     113      series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
     114      series1.Name = "Bubbles";
     115      series1.YValuesPerPoint = 2;
     116      this.chart.Series.Add(series1);
    116117      this.chart.Size = new System.Drawing.Size(966, 668);
    117118      this.chart.TabIndex = 7;
    118119      this.chart.AxisViewChanged += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.ViewEventArgs>(this.chart_AxisViewChanged);
     120      this.chart.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDoubleClick);
     121      this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
    119122      //
    120123      // yAxisComboBox
     
    184187      this.splitContainer.SplitterDistance = 107;
    185188      this.splitContainer.TabIndex = 12;
     189      //
     190      // noDataLabel
     191      //
     192      this.noDataLabel.Anchor = System.Windows.Forms.AnchorStyles.None;
     193      this.noDataLabel.AutoSize = true;
     194      this.noDataLabel.Location = new System.Drawing.Point(469, 323);
     195      this.noDataLabel.Name = "noDataLabel";
     196      this.noDataLabel.Size = new System.Drawing.Size(139, 13);
     197      this.noDataLabel.TabIndex = 8;
     198      this.noDataLabel.Text = "No data could be displayed.";
     199      this.noDataLabel.Visible = false;
    186200      //
    187201      // sizeComboBox
     
    291305      this.xJitterTrackBar.TickStyle = System.Windows.Forms.TickStyle.None;
    292306      this.xJitterTrackBar.ValueChanged += new System.EventHandler(this.jitterTrackBar_ValueChanged);
    293       //
    294       // noDataLabel
    295       //
    296       this.noDataLabel.Anchor = System.Windows.Forms.AnchorStyles.None;
    297       this.noDataLabel.AutoSize = true;
    298       this.noDataLabel.Location = new System.Drawing.Point(469, 323);
    299       this.noDataLabel.Name = "noDataLabel";
    300       this.noDataLabel.Size = new System.Drawing.Size(139, 13);
    301       this.noDataLabel.TabIndex = 8;
    302       this.noDataLabel.Text = "No data could be displayed.";
    303       this.noDataLabel.Visible = false;
    304307      //
    305308      // BubbleChartView
     
    363366    private System.Windows.Forms.TrackBar xJitterTrackBar;
    364367    private System.Windows.Forms.Label noDataLabel;
     368    private System.Windows.Forms.ToolTip tooltip;
    365369  }
    366370}
  • branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3/BubbleChartView.cs

    r12882 r12884  
    567567    }
    568568
     569    private void chart_MouseMove(object sender, MouseEventArgs e) {
     570      if (Control.MouseButtons != MouseButtons.None) return;
     571      HitTestResult h = this.chart.HitTest(e.X, e.Y);
     572      string newTooltipText = string.Empty;
     573      string oldTooltipText;
     574      if (h.ChartElementType == ChartElementType.DataPoint) {
     575        var tag = (Tuple<double, double, RecursiveDataItem, RecursiveDataItem>)((DataPoint)h.Object).Tag;
     576        newTooltipText = BuildTooltip(tag);
     577      } else if (h.ChartElementType == ChartElementType.AxisLabels) {
     578        newTooltipText = ((CustomLabel)h.Object).ToolTip;
     579      }
     580
     581      oldTooltipText = this.tooltip.GetToolTip(chart);
     582      if (newTooltipText != oldTooltipText)
     583        this.tooltip.SetToolTip(chart, newTooltipText);
     584    }
     585
     586    private string BuildTooltip(Tuple<double, double, RecursiveDataItem, RecursiveDataItem> tag) {
     587      string tooltip;
     588      if (tag.Item3 != tag.Item4)
     589        tooltip = "X: " + tag.Item3.Name + Environment.NewLine + "Y: " + tag.Item4.Name + Environment.NewLine;
     590      else
     591        tooltip = tag.Item3.Name + Environment.NewLine;
     592
     593      double? xValue = tag.Item1;
     594      double? yValue = tag.Item2;
     595      //double? sizeValue = this.GetValue(run, (string)sizeComboBox.SelectedItem);
     596
     597      string xString = xValue == null ? string.Empty : xValue.Value.ToString();
     598      string yString = yValue == null ? string.Empty : yValue.Value.ToString();
     599      //string sizeString = sizeValue == null ? string.Empty : sizeValue.Value.ToString();
     600
     601      // TODO
     602      ////code to handle TimeSpanValues correct
     603      //int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count();
     604      //int columnIndex = xAxisComboBox.SelectedIndex - axisDimensionCount;
     605      //if (xValue.HasValue && columnIndex > 0 && Content.GetValue(0, columnIndex) is TimeSpanValue) {
     606      //  TimeSpan time = TimeSpan.FromSeconds(xValue.Value);
     607      //  xString = string.Format("{0:00}:{1:00}:{2:00.00}", (int)time.TotalHours, time.Minutes, time.Seconds);
     608      //}
     609      //columnIndex = yAxisComboBox.SelectedIndex - axisDimensionCount;
     610      //if (yValue.HasValue && columnIndex > 0 && Content.GetValue(0, columnIndex) is TimeSpanValue) {
     611      //  TimeSpan time = TimeSpan.FromSeconds(yValue.Value);
     612      //  yString = string.Format("{0:00}:{1:00}:{2:00.00}", (int)time.TotalHours, time.Minutes, time.Seconds);
     613      //}
     614
     615      tooltip += xAxisComboBox.SelectedItem + " : " + xString + Environment.NewLine;
     616      tooltip += yAxisComboBox.SelectedItem + " : " + yString + Environment.NewLine;
     617      //tooltip += sizeComboBox.SelectedItem + " : " + sizeString + Environment.NewLine;
     618
     619      return tooltip;
     620    }
     621
     622    private void chart_MouseDoubleClick(object sender, MouseEventArgs e) {
     623      HitTestResult h = this.chart.HitTest(e.X, e.Y, ChartElementType.DataPoint);
     624      if (h.ChartElementType == ChartElementType.DataPoint) {
     625        var tuple = (Tuple<double, double, RecursiveDataItem, RecursiveDataItem>)((DataPoint)h.Object).Tag;
     626        IContentView view = MainFormManager.MainForm.ShowContent(tuple.Item3, typeof(RecursiveDataItemView));
     627        if (view != null) {
     628          view.ReadOnly = this.ReadOnly;
     629          view.Locked = this.Locked;
     630        }
     631        if (tuple.Item3 != tuple.Item4) {
     632          view = MainFormManager.MainForm.ShowContent(tuple.Item4, typeof(RecursiveDataItemView));
     633          if (view != null) {
     634            view.ReadOnly = this.ReadOnly;
     635            view.Locked = this.Locked;
     636          }
     637        }
     638
     639        this.chart.ChartAreas[0].CursorX.SelectionStart = this.chart.ChartAreas[0].CursorX.SelectionEnd;
     640        this.chart.ChartAreas[0].CursorY.SelectionStart = this.chart.ChartAreas[0].CursorY.SelectionEnd;
     641      }
     642      UpdateAxisLabels();
     643    }
    569644    #endregion
    570645
Note: See TracChangeset for help on using the changeset viewer.