- Timestamp:
- 10/28/10 17:38:37 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBoxPlotView.cs
r4211 r4652 25 25 using System.Windows.Forms; 26 26 using System.Windows.Forms.DataVisualization.Charting; 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; 28 29 using HeuristicLab.Data; … … 50 51 this.chart.Series.Clear(); 51 52 this.chart.ChartAreas.Add(BoxPlotChartAreaName); 53 this.chart.CustomizeAllChartAreas(); 52 54 } 53 55 … … 168 170 this.chart.Series.Add(s); 169 171 172 UpdateStatistics(); 170 173 if (seriesCache.Count > 0) { 171 174 Series boxPlotSeries = CreateBoxPlotSeries(); … … 176 179 } 177 180 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; 178 222 } 179 223 … … 214 258 Series series = seriesCache[xValue.Value]; 215 259 DataPoint point = new DataPoint(xValue.Value, yValue.Value); 260 point.Tag = run; 216 261 series.Points.Add(point); 217 262 } … … 293 338 SetCustomAxisLabels(xAxis, xAxisComboBox.SelectedIndex - axisDimensionCount); 294 339 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(); 295 344 } 296 345 … … 340 389 } 341 390 } 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 } 342 404 #endregion 405 343 406 } 344 407 }
Note: See TracChangeset
for help on using the changeset viewer.