Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4049


Ignore:
Timestamp:
07/19/10 17:31:28 (14 years ago)
Author:
mkommend
Message:

adapted bubble chart to handle TimeSpanValues correctly (ticket #1047)

Location:
trunk/sources/HeuristicLab.Optimization.Views/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.Designer.cs

    r3742 r4049  
    199199      this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
    200200      this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
     201      this.chart.AxisViewChanged += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.ViewEventArgs>(chart_AxisViewChanged);
    201202      //
    202203      // zoomButton
     
    293294      this.ResumeLayout(false);
    294295      this.PerformLayout();
    295 
    296296    }
    297 
    298297    #endregion
    299298
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.cs

    r3764 r4049  
    137137      } else
    138138        AddDataPoint(run);
    139         UpdateCursorInterval();
     139      UpdateCursorInterval();
    140140
    141141
     
    275275        DoubleValue doubleValue = value as DoubleValue;
    276276        IntValue intValue = value as IntValue;
     277        TimeSpanValue timeSpanValue = value as TimeSpanValue;
    277278        double? ret = null;
    278279        if (doubleValue != null) {
     
    281282        } else if (intValue != null)
    282283          ret = intValue.Value;
    283         else
     284        else if (timeSpanValue != null) {
     285          ret = timeSpanValue.Value.TotalSeconds;
     286        } else
    284287          ret = GetCategoricalValue(columnIndex, value.ToString());
    285288
     
    339342      double xRange = xValues.Max() - xValues.Min();
    340343      double yRange = yValues.Max() - yValues.Min();
    341       if(xRange.IsAlmost(0.0)) xRange = 1.0;
    342       if(yRange.IsAlmost(0.0)) yRange = 1.0;
     344      if (xRange.IsAlmost(0.0)) xRange = 1.0;
     345      if (yRange.IsAlmost(0.0)) yRange = 1.0;
    343346      double xDigits = (int)Math.Log10(xRange) - 3;
    344347      double yDigits = (int)Math.Log10(yRange) - 3;
     
    347350      this.chart.ChartAreas[0].CursorX.Interval = xZoomInterval;
    348351      this.chart.ChartAreas[0].CursorY.Interval = yZoomInterval;
     352
     353      //code to handle TimeSpanValues correct
     354      int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count();
     355      int columnIndex = xAxisComboBox.SelectedIndex - axisDimensionCount;
     356      if (columnIndex >= 0 && Content.GetValue(0, columnIndex) is TimeSpanValue)
     357        this.chart.ChartAreas[0].CursorX.Interval = 1;
     358      columnIndex = yAxisComboBox.SelectedIndex - axisDimensionCount;
     359      if (columnIndex >= 0 && Content.GetValue(0, columnIndex) is TimeSpanValue)
     360        this.chart.ChartAreas[0].CursorY.Interval = 1;
    349361    }
    350362
     
    447459      string sizeString = sizeValue == null ? string.Empty : sizeValue.Value.ToString();
    448460
     461      //code to handle TimeSpanValues correct
     462      int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count();
     463      int columnIndex = xAxisComboBox.SelectedIndex - axisDimensionCount;
     464      if (xValue.HasValue && columnIndex > 0 && Content.GetValue(0, columnIndex) is TimeSpanValue) {
     465        TimeSpan time = TimeSpan.FromSeconds(xValue.Value);
     466        xString = string.Format("{0:00}:{1:00}:{2:00.00}", (int)time.TotalHours, time.Minutes, time.TotalSeconds);
     467      }
     468      columnIndex = yAxisComboBox.SelectedIndex - axisDimensionCount;
     469      if (yValue.HasValue && columnIndex > 0 && Content.GetValue(0, columnIndex) is TimeSpanValue) {
     470        TimeSpan time = TimeSpan.FromSeconds(yValue.Value);
     471        yString = string.Format("{0:00}:{1:00}:{2:00.00}", (int)time.TotalHours, time.Minutes, time.TotalSeconds);
     472      }
     473
    449474      tooltip += xAxisComboBox.SelectedItem + " : " + xString + Environment.NewLine;
    450475      tooltip += yAxisComboBox.SelectedItem + " : " + yString + Environment.NewLine;
     
    483508      SetCustomAxisLabels(yAxis, yAxisComboBox.SelectedIndex - axisDimensionCount);
    484509    }
     510
     511    private void chart_AxisViewChanged(object sender, System.Windows.Forms.DataVisualization.Charting.ViewEventArgs e) {
     512      this.UpdateAxisLabels();
     513    }
     514
    485515    private void SetCustomAxisLabels(Axis axis, int dimension) {
    486516      axis.CustomLabels.Clear();
     
    498528        axis.LabelStyle.Angle = 0;
    499529        axis.LabelStyle.TruncatedLabels = true;
     530      } else if (dimension > 0 && Content.GetValue(0, dimension) is TimeSpanValue) {
     531        this.chart.ChartAreas[0].RecalculateAxesScale();
     532        for (double i = axis.Minimum; i <= axis.Maximum; i += axis.LabelStyle.Interval) {
     533          TimeSpan time = TimeSpan.FromSeconds(i);
     534          string x = string.Format("{0:00}:{1:00}:{2:00.00}", (int)time.TotalHours, time.Minutes, time.TotalSeconds);
     535          axis.CustomLabels.Add(i - 0.5, i + 0.5, x);
     536        }
    500537      }
    501538    }
Note: See TracChangeset for help on using the changeset viewer.