Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12882 for branches/BubbleChart


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

#2379
Fixed zooming issues.
Added "no data available" label.

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

    r12881 r12882  
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
    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();
     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();
    5050      this.yLabel = new System.Windows.Forms.Label();
    5151      this.xLabel = new System.Windows.Forms.Label();
     
    6666      this.yJitterTrackBar = new System.Windows.Forms.TrackBar();
    6767      this.xJitterTrackBar = new System.Windows.Forms.TrackBar();
     68      this.noDataLabel = new System.Windows.Forms.Label();
    6869      ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
    6970      this.childrenGroupBox.SuspendLayout();
     
    102103            | System.Windows.Forms.AnchorStyles.Left)
    103104            | System.Windows.Forms.AnchorStyles.Right)));
    104       chartArea1.Name = "ChartArea1";
    105       this.chart.ChartAreas.Add(chartArea1);
     105      chartArea2.Name = "ChartArea1";
     106      this.chart.ChartAreas.Add(chartArea2);
    106107      this.chart.Location = new System.Drawing.Point(3, 3);
    107108      this.chart.Name = "chart";
    108       series1.ChartArea = "ChartArea1";
    109       series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
    110       series1.IsVisibleInLegend = false;
    111       series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
    112       series1.Name = "Bubbles";
    113       series1.YValuesPerPoint = 2;
    114       this.chart.Series.Add(series1);
     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);
    115116      this.chart.Size = new System.Drawing.Size(966, 668);
    116117      this.chart.TabIndex = 7;
     
    178179      // splitContainer.Panel2
    179180      //
     181      this.splitContainer.Panel2.Controls.Add(this.noDataLabel);
    180182      this.splitContainer.Panel2.Controls.Add(this.chart);
    181183      this.splitContainer.Size = new System.Drawing.Size(1083, 674);
     
    289291      this.xJitterTrackBar.TickStyle = System.Windows.Forms.TickStyle.None;
    290292      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;
    291304      //
    292305      // BubbleChartView
     
    317330      this.splitContainer.Panel1.ResumeLayout(false);
    318331      this.splitContainer.Panel2.ResumeLayout(false);
     332      this.splitContainer.Panel2.PerformLayout();
    319333      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    320334      this.splitContainer.ResumeLayout(false);
     
    348362    private System.Windows.Forms.TrackBar yJitterTrackBar;
    349363    private System.Windows.Forms.TrackBar xJitterTrackBar;
     364    private System.Windows.Forms.Label noDataLabel;
    350365  }
    351366}
  • branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3/BubbleChartView.cs

    r12881 r12882  
    197197      chart.ChartAreas[0].AxisY.IsMarginVisible = !(YAxisValue != null && YAxisValue.Contains(AxisDimension.Index.ToString()));
    198198
    199       if (Content == null || string.IsNullOrEmpty(XAxisValue) || string.IsNullOrEmpty(YAxisValue)) return;
    200 
    201       var xss = GetValues(XAxisValue);
    202       var yss = GetValues(YAxisValue);
    203 
    204       if (xss.Count == yss.Count) {
    205         for (int i = 0; i < xss.Count; i++)
    206           AddPoints(xss[i], yss[i], series);
    207       } else if (xss.Count == 1 || yss.Count == 1) {
    208         for (int i = 0; i < xss.Count; i++)
    209           for (int j = 0; j < yss.Count; j++)
    210             AddPoints(xss[i], yss[j], series);
     199      if (Content != null && !string.IsNullOrEmpty(XAxisValue) && !string.IsNullOrEmpty(YAxisValue)) {
     200        var xss = GetValues(XAxisValue);
     201        var yss = GetValues(YAxisValue);
     202
     203        if (xss.Count == yss.Count) {
     204          for (int i = 0; i < xss.Count; i++)
     205            AddPoints(xss[i], yss[i], series);
     206        } else if (xss.Count == 1 || yss.Count == 1) {
     207          for (int i = 0; i < xss.Count; i++)
     208            for (int j = 0; j < yss.Count; j++)
     209              AddPoints(xss[i], yss[j], series);
     210        }
     211      }
     212
     213      if (chart.Series[0].Points.Count == 0) {
     214        noDataLabel.Visible = true;
     215      } else {
     216        noDataLabel.Visible = false;
     217        UpdateMarkerSizes();
     218        UpdateCursorInterval();
    211219      }
    212220
     
    520528      }
    521529    }
     530    private void UpdateCursorInterval() {
     531      double xMin = double.MaxValue;
     532      double xMax = double.MinValue;
     533      double yMin = double.MaxValue;
     534      double yMax = double.MinValue;
     535
     536      foreach (var point in chart.Series[0].Points) {
     537        if (point.IsEmpty) continue;
     538        if (point.XValue < xMin) xMin = point.XValue;
     539        if (point.XValue > xMax) xMax = point.XValue;
     540        if (point.YValues[0] < yMin) yMin = point.YValues[0];
     541        if (point.YValues[0] > yMax) yMax = point.YValues[0];
     542      }
     543
     544      double xRange = 0.0;
     545      double yRange = 0.0;
     546      if (xMin != double.MaxValue && xMax != double.MinValue) xRange = xMax - xMin;
     547      if (yMin != double.MaxValue && yMax != double.MinValue) yRange = yMax - yMin;
     548
     549      if (xRange.IsAlmost(0.0)) xRange = 1.0;
     550      if (yRange.IsAlmost(0.0)) yRange = 1.0;
     551      double xDigits = (int)Math.Log10(xRange) - 3;
     552      double yDigits = (int)Math.Log10(yRange) - 3;
     553      double xZoomInterval = Math.Pow(10, xDigits);
     554      double yZoomInterval = Math.Pow(10, yDigits);
     555      this.chart.ChartAreas[0].CursorX.Interval = xZoomInterval;
     556      this.chart.ChartAreas[0].CursorY.Interval = yZoomInterval;
     557
     558      // TODO
     559      //code to handle TimeSpanValues correct
     560      //int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count();
     561      //int columnIndex = xAxisComboBox.SelectedIndex - axisDimensionCount;
     562      //if (columnIndex >= 0 && Content.GetValue(0, columnIndex) is TimeSpanValue)
     563      //  this.chart.ChartAreas[0].CursorX.Interval = 1;
     564      //columnIndex = yAxisComboBox.SelectedIndex - axisDimensionCount;
     565      //if (columnIndex >= 0 && Content.GetValue(0, columnIndex) is TimeSpanValue)
     566      //  this.chart.ChartAreas[0].CursorY.Interval = 1;
     567    }
     568
    522569    #endregion
    523570
Note: See TracChangeset for help on using the changeset viewer.