Changeset 9190


Ignore:
Timestamp:
01/25/13 16:20:13 (8 years ago)
Author:
abeham
Message:

#2008: Added option to obtain a matrix representation of a bubble chart view

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

Legend:

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

    r7967 r9190  
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
    48       System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
    49       System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
     48      System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
     49      System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
    5050      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RunCollectionBubbleChartView));
    5151      this.yJitterLabel = new System.Windows.Forms.Label();
     
    7272      this.noRunsLabel = new System.Windows.Forms.Label();
    7373      this.sizeTrackBar = new System.Windows.Forms.TrackBar();
     74      this.getDataAsMatrixToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    7475      ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).BeginInit();
    7576      ((System.ComponentModel.ISupportInitialize)(this.yTrackBar)).BeginInit();
     
    188189      //
    189190      this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    190                   | System.Windows.Forms.AnchorStyles.Left)
    191                   | System.Windows.Forms.AnchorStyles.Right)));
    192       chartArea2.Name = "ChartArea1";
    193       this.chart.ChartAreas.Add(chartArea2);
     191            | System.Windows.Forms.AnchorStyles.Left)
     192            | System.Windows.Forms.AnchorStyles.Right)));
     193      chartArea1.Name = "ChartArea1";
     194      this.chart.ChartAreas.Add(chartArea1);
    194195      this.chart.Location = new System.Drawing.Point(6, 30);
    195196      this.chart.Name = "chart";
    196       series2.ChartArea = "ChartArea1";
    197       series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
    198       series2.IsVisibleInLegend = false;
    199       series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
    200       series2.Name = "Bubbles";
    201       series2.YValuesPerPoint = 2;
    202       this.chart.Series.Add(series2);
     197      series1.ChartArea = "ChartArea1";
     198      series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
     199      series1.IsVisibleInLegend = false;
     200      series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
     201      series1.Name = "Bubbles";
     202      series1.YValuesPerPoint = 2;
     203      this.chart.Series.Add(series1);
    203204      this.chart.Size = new System.Drawing.Size(843, 425);
    204205      this.chart.TabIndex = 16;
     
    215216      this.openBoxPlotViewToolStripMenuItem.Text = "Open BoxPlot View";
    216217      this.openBoxPlotViewToolStripMenuItem.Click += new System.EventHandler(this.openBoxPlotViewToolStripMenuItem_Click);
    217       //
     218      // 
    218219      // hideRunToolStripMenuItem
    219       //
     220      // 
    220221      this.hideRunToolStripMenuItem.Name = "hideRunToolStripMenuItem";
    221222      this.hideRunToolStripMenuItem.Size = new System.Drawing.Size(256, 22);
    222223      this.hideRunToolStripMenuItem.Text = "Hide Run";
    223       this.hideRunToolStripMenuItem.Click += new System.EventHandler(hideRunToolStripMenuItem_Click);
     224      this.hideRunToolStripMenuItem.Click += new System.EventHandler(this.hideRunToolStripMenuItem_Click);
    224225      //
    225226      // zoomButton
     
    325326      this.sizeTrackBar.Value = 10;
    326327      this.sizeTrackBar.ValueChanged += new System.EventHandler(this.sizeTrackBar_ValueChanged);
     328      //
     329      // ToolStripMenuItem
     330      //
     331      this.getDataAsMatrixToolStripMenuItem.Name = "getDataAsMatrixToolStripMenuItem";
     332      this.getDataAsMatrixToolStripMenuItem.Size = new System.Drawing.Size(256, 22);
     333      this.getDataAsMatrixToolStripMenuItem.Text = "Get Data as Matrix";
     334      this.getDataAsMatrixToolStripMenuItem.Click += new System.EventHandler(this.getDataAsMatrixToolStripMenuItem_Click);
    327335      //
    328336      // RunCollectionBubbleChartView
     
    386394    private System.Windows.Forms.Button colorYAxisButton;
    387395    private System.Windows.Forms.TrackBar sizeTrackBar;
     396    private System.Windows.Forms.ToolStripMenuItem getDataAsMatrixToolStripMenuItem;
    388397  }
    389398}
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs

    r9068 r9190  
    2020#endregion
    2121
     22using HeuristicLab.Common;
     23using HeuristicLab.Core;
     24using HeuristicLab.Data;
     25using HeuristicLab.MainForm;
     26using HeuristicLab.MainForm.WindowsForms;
    2227using System;
    2328using System.Collections.Generic;
     
    2631using System.Windows.Forms;
    2732using System.Windows.Forms.DataVisualization.Charting;
    28 using HeuristicLab.Common;
    29 using HeuristicLab.Core;
    30 using HeuristicLab.Data;
    31 using HeuristicLab.MainForm;
    32 using HeuristicLab.MainForm.WindowsForms;
    3333
    3434namespace HeuristicLab.Optimization.Views {
     
    5858      chart.ContextMenuStrip.Items.Insert(0, hideRunToolStripMenuItem);
    5959      chart.ContextMenuStrip.Items.Insert(1, openBoxPlotViewToolStripMenuItem);
     60      chart.ContextMenuStrip.Items.Add(getDataAsMatrixToolStripMenuItem);
    6061      chart.ContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(ContextMenuStrip_Opening);
    6162
     
    688689      boxplotView.Show();
    689690    }
     691
     692    private void getDataAsMatrixToolStripMenuItem_Click(object sender, EventArgs e) {
     693      int xCol = Matrix.ColumnNames.ToList().IndexOf(xAxisValue);
     694      var grouped = new Dictionary<string, List<string>>();
     695      Dictionary<double, string> reverseMapping = null;
     696      if (categoricalMapping.ContainsKey(xCol))
     697        reverseMapping = categoricalMapping[xCol].ToDictionary(x => x.Value, y => y.Key.ToString());
     698      foreach (var run in Content.Where(r => r.Visible)) {
     699        var x = GetValue(run, xAxisValue);
     700        var y = GetValue(run, yAxisValue);
     701        if (!(x.HasValue && y.HasValue)) continue;
     702
     703        var category = reverseMapping == null ? x.Value.ToString() : reverseMapping[x.Value];
     704        if (!grouped.ContainsKey(category)) grouped[category] = new List<string>();
     705        grouped[category].Add(y.Value.ToString());
     706      }
     707
     708      if (!grouped.Any()) return;
     709      var matrix = new StringMatrix(grouped.Values.Max(x => x.Count), grouped.Count) {
     710        ColumnNames = grouped.Keys.ToArray()
     711      };
     712      int i = 0;
     713      foreach (var col in matrix.ColumnNames) {
     714        int j = 0;
     715        foreach (var y in grouped[col])
     716          matrix[j++, i] = y;
     717        i++;
     718      }
     719
     720      MainFormManager.MainForm.ShowContent(matrix);
     721    }
    690722    #endregion
    691723
Note: See TracChangeset for help on using the changeset viewer.