Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/28/10 17:38:37 (13 years ago)
Author:
mkommend
Message:

Added statistical information to the RunCollectionBoxPlotView and corrected minor bugs in the 'RunCollectionBubbleChartView' and the 'RunCollectionBoxPlotView' (ticket #1135).

File:
1 edited

Legend:

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

    r4211 r4652  
    2525using System.Windows.Forms;
    2626using System.Windows.Forms.DataVisualization.Charting;
     27using HeuristicLab.Common;
    2728using HeuristicLab.Core;
    2829using HeuristicLab.Data;
     
    5051      this.chart.Series.Clear();
    5152      this.chart.ChartAreas.Add(BoxPlotChartAreaName);
     53      this.chart.CustomizeAllChartAreas();
    5254    }
    5355
     
    168170          this.chart.Series.Add(s);
    169171
     172        UpdateStatistics();
    170173        if (seriesCache.Count > 0) {
    171174          Series boxPlotSeries = CreateBoxPlotSeries();
     
    176179      }
    177180      UpdateNoRunsVisibleLabel();
     181    }
     182
     183    private void UpdateStatistics() {
     184      DoubleMatrix matrix = new DoubleMatrix(6, seriesCache.Count);
     185      matrix.SortableView = false;
     186      List<string> columnNames = new List<string>();
     187      foreach (Series series in seriesCache.Values) {
     188        DataPoint datapoint = series.Points.FirstOrDefault();
     189        if (datapoint != null) {
     190          IRun run = (IRun)datapoint.Tag;
     191          string selectedAxis = (string)xAxisComboBox.SelectedItem;
     192          IItem value = null;
     193
     194          if (Enum.IsDefined(typeof(AxisDimension), selectedAxis)) {
     195            AxisDimension axisDimension = (AxisDimension)Enum.Parse(typeof(AxisDimension), selectedAxis);
     196            switch (axisDimension) {
     197              case AxisDimension.Color: value = new StringValue(run.Color.ToString());
     198                break;
     199            }
     200          } else value = Content.GetValue(run, selectedAxis);
     201          string columnName = string.Empty;
     202          if (value is DoubleValue || value is IntValue)
     203            columnName = selectedAxis + ": ";
     204          columnName += value.ToString();
     205          columnNames.Add(columnName);
     206        }
     207      }
     208      matrix.ColumnNames = columnNames;
     209      matrix.RowNames = new string[] { "Mean", "Median", "Standard deviation", "Variance", "25th percentile", "75th percentile" };
     210
     211      for (int i = 0; i < seriesCache.Count; i++) {
     212        Series series = seriesCache.ElementAt(i).Value;
     213        double[] seriesValues = series.Points.Select(p => p.YValues[0]).OrderBy(d => d).ToArray();
     214        matrix[0, i] = seriesValues.Average();
     215        matrix[1, i] = seriesValues.Median();
     216        matrix[2, i] = seriesValues.StandardDeviation();
     217        matrix[3, i] = seriesValues.Variance();
     218        matrix[4, i] = seriesValues.Percentile(0.25);
     219        matrix[5, i] = seriesValues.Percentile(0.75);
     220      }
     221      statisticsMatrixView.Content = matrix;
    178222    }
    179223
     
    214258        Series series = seriesCache[xValue.Value];
    215259        DataPoint point = new DataPoint(xValue.Value, yValue.Value);
     260        point.Tag = run;
    216261        series.Points.Add(point);
    217262      }
     
    293338      SetCustomAxisLabels(xAxis, xAxisComboBox.SelectedIndex - axisDimensionCount);
    294339      SetCustomAxisLabels(yAxis, yAxisComboBox.SelectedIndex - axisDimensionCount);
     340      if (xAxisComboBox.SelectedItem != null)
     341        xAxis.Title = xAxisComboBox.SelectedItem.ToString();
     342      if (yAxisComboBox.SelectedItem != null)
     343        yAxis.Title = yAxisComboBox.SelectedItem.ToString();
    295344    }
    296345
     
    340389      }
    341390    }
     391
     392    private void chart_MouseMove(object sender, MouseEventArgs e) {
     393      string newTooltipText = string.Empty;
     394      string oldTooltipText;
     395      HitTestResult h = this.chart.HitTest(e.X, e.Y);
     396      if (h.ChartElementType == ChartElementType.AxisLabels) {
     397        newTooltipText = ((CustomLabel)h.Object).ToolTip;
     398      }
     399
     400      oldTooltipText = this.tooltip.GetToolTip(chart);
     401      if (newTooltipText != oldTooltipText)
     402        this.tooltip.SetToolTip(chart, newTooltipText);
     403    }
    342404    #endregion
     405
    343406  }
    344407}
Note: See TracChangeset for help on using the changeset viewer.