Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/17/17 14:58:30 (7 years ago)
Author:
mkommend
Message:

#2810: Corrected tooltip for non-numerical values.

File:
1 edited

Legend:

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

    r15122 r15264  
    435435        return GetValue(run, sizeDimension);
    436436      } else {
    437         int columnIndex = Matrix.ColumnNames.ToList().IndexOf(columnName);
    438         IItem value = Content.GetValue(run, columnIndex);
     437
     438        IItem value = Content.GetValue(run, columnName);
    439439        if (value == null)
    440440          return null;
     
    451451        else if (timeSpanValue != null) {
    452452          ret = timeSpanValue.Value.TotalSeconds;
    453         } else
     453        } else {
     454          int columnIndex = Matrix.ColumnNames.ToList().IndexOf(columnName);
    454455          ret = GetCategoricalValue(columnIndex, value.ToString());
     456        }
    455457
    456458        return ret;
     
    622624      tooltip = run.Name + System.Environment.NewLine;
    623625
    624       double? xValue = this.GetValue(run, (string)xAxisComboBox.SelectedItem);
    625       double? yValue = this.GetValue(run, (string)yAxisComboBox.SelectedItem);
    626       double? sizeValue = this.GetValue(run, (string)sizeComboBox.SelectedItem);
    627 
    628       string xString = xValue == null ? string.Empty : xValue.Value.ToString();
    629       string yString = yValue == null ? string.Empty : yValue.Value.ToString();
    630       string sizeString = sizeValue == null ? string.Empty : sizeValue.Value.ToString();
    631 
    632       //code to handle TimeSpanValues correct
    633       int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count();
    634       int columnIndex = xAxisComboBox.SelectedIndex - axisDimensionCount;
    635       if (xValue.HasValue && columnIndex > 0 && Content.GetValue(0, columnIndex) is TimeSpanValue) {
    636         TimeSpan time = TimeSpan.FromSeconds(xValue.Value);
    637         xString = string.Format("{0:00}:{1:00}:{2:00.00}", (int)time.TotalHours, time.Minutes, time.Seconds);
    638       }
    639       columnIndex = yAxisComboBox.SelectedIndex - axisDimensionCount;
    640       if (yValue.HasValue && columnIndex > 0 && Content.GetValue(0, columnIndex) is TimeSpanValue) {
    641         TimeSpan time = TimeSpan.FromSeconds(yValue.Value);
    642         yString = string.Format("{0:00}:{1:00}:{2:00.00}", (int)time.TotalHours, time.Minutes, time.Seconds);
    643       }
     626      string xString = GetTooltipValue(run, (string)xAxisComboBox.SelectedItem);
     627      string yString = GetTooltipValue(run, (string)yAxisComboBox.SelectedItem);
     628      string sizeString = GetTooltipValue(run, (string)sizeComboBox.SelectedItem);
    644629
    645630      tooltip += xAxisComboBox.SelectedItem + " : " + xString + Environment.NewLine;
     
    648633
    649634      return tooltip;
     635    }
     636
     637    private string GetTooltipValue(IRun run, string columnName) {
     638      int columnIndex = Matrix.ColumnNames.ToList().IndexOf(columnName);
     639
     640      //handle non-numeric values correctly
     641      if (categoricalMapping.ContainsKey(columnIndex)) {
     642        return Content.GetValue(run, columnName).ToString();
     643      }
     644
     645      double? value = GetValue(run, columnName);
     646      if (!value.HasValue) return string.Empty;
     647
     648      string valueString = value.Value.ToString();
     649
     650      //code to handle TimeSpanValues correctly
     651      if (columnIndex > 0 && Content.GetValue(0, columnIndex) is TimeSpanValue) {
     652        TimeSpan time = TimeSpan.FromSeconds(value.Value);
     653        valueString = string.Format("{0:00}:{1:00}:{2:00.00}", (int)time.TotalHours, time.Minutes, time.Seconds);
     654      }
     655
     656      return valueString;
    650657    }
    651658    #endregion
Note: See TracChangeset for help on using the changeset viewer.