Changeset 16681


Ignore:
Timestamp:
03/13/19 11:49:32 (8 days ago)
Author:
bburlacu
Message:

#2995: Handle DateTimeValues correctly.

File:
1 edited

Legend:

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

    r16565 r16681  
    2424using System.ComponentModel;
    2525using System.Drawing;
     26using System.Globalization;
    2627using System.Linq;
    2728using System.Windows.Forms;
     
    443444        IntValue intValue = value as IntValue;
    444445        TimeSpanValue timeSpanValue = value as TimeSpanValue;
     446        DateTimeValue dateTimeValue = value as DateTimeValue;
    445447        double? ret = null;
    446448        if (doubleValue != null) {
     
    451453        else if (timeSpanValue != null) {
    452454          ret = timeSpanValue.Value.TotalSeconds;
     455        } else if (dateTimeValue != null) {
     456          ret = dateTimeValue.Value.ToOADate();
    453457        } else {
    454458          int columnIndex = Matrix.ColumnNames.ToList().IndexOf(columnName);
     
    531535      int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count();
    532536      int columnIndex = xAxisComboBox.SelectedIndex - axisDimensionCount;
    533       if (columnIndex >= 0 && Content.GetValue(0, columnIndex) is TimeSpanValue)
    534         this.chart.ChartAreas[0].CursorX.Interval = 1;
     537      if (columnIndex >= 0) {
     538        var value = Content.GetValue(0, columnIndex);
     539        if (value is TimeSpanValue || value is DateTimeValue)
     540          this.chart.ChartAreas[0].CursorX.Interval = 1;
     541      }
    535542      columnIndex = yAxisComboBox.SelectedIndex - axisDimensionCount;
    536       if (columnIndex >= 0 && Content.GetValue(0, columnIndex) is TimeSpanValue)
    537         this.chart.ChartAreas[0].CursorY.Interval = 1;
     543      if (columnIndex >= 0) {
     544        var value = Content.GetValue(0, columnIndex);
     545        if (value is TimeSpanValue || value is DateTimeValue)
     546          this.chart.ChartAreas[0].CursorY.Interval = 1;
     547      }
    538548    }
    539549
     
    734744          axis.CustomLabels.Add(i - axis.LabelStyle.Interval / 2, i + axis.LabelStyle.Interval / 2, x);
    735745        }
     746      } else if (dimension > 0 && Content.GetValue(0, dimension) is DateTimeValue) {
     747        this.chart.ChartAreas[0].RecalculateAxesScale();
     748        for (double i = axis.Minimum; i <= axis.Maximum; i += axis.LabelStyle.Interval) {
     749          DateTime dt = DateTime.FromOADate(i);
     750          string x = dt.ToString(CultureInfo.CurrentCulture);
     751          axis.CustomLabels.Add(i - axis.LabelStyle.Interval / 2, i + axis.LabelStyle.Interval / 2, x);
     752        }
    736753      }
    737754    }
Note: See TracChangeset for help on using the changeset viewer.