Changeset 12498


Ignore:
Timestamp:
06/23/15 13:31:49 (4 years ago)
Author:
pfleck
Message:

#2379

  • Adapted parts of categorical mapping from RunCollectionBubbleChart.
  • Small changes and optimizations.
  • Updated ALPS sample.
Location:
branches/BubbleChart
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3/BubbleChartView.Designer.cs

    r12459 r12498  
    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      this.yLabel = new System.Windows.Forms.Label();
    5151      this.xLabel = new System.Windows.Forms.Label();
     
    9494            | System.Windows.Forms.AnchorStyles.Left)
    9595            | System.Windows.Forms.AnchorStyles.Right)));
    96       chartArea2.Name = "ChartArea1";
    97       this.chart.ChartAreas.Add(chartArea2);
     96      chartArea1.Name = "ChartArea1";
     97      this.chart.ChartAreas.Add(chartArea1);
    9898      this.chart.Location = new System.Drawing.Point(3, 3);
    9999      this.chart.Name = "chart";
    100       series2.ChartArea = "ChartArea1";
    101       series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
    102       series2.IsVisibleInLegend = false;
    103       series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
    104       series2.Name = "Bubbles";
    105       series2.YValuesPerPoint = 2;
    106       this.chart.Series.Add(series2);
     100      series1.ChartArea = "ChartArea1";
     101      series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
     102      series1.IsVisibleInLegend = false;
     103      series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
     104      series1.Name = "Bubbles";
     105      series1.YValuesPerPoint = 2;
     106      this.chart.Series.Add(series1);
    107107      this.chart.Size = new System.Drawing.Size(880, 668);
    108108      this.chart.TabIndex = 7;
     
    216216      //
    217217      this.includeChildrenCheckBox.AutoSize = true;
     218      this.includeChildrenCheckBox.Checked = true;
     219      this.includeChildrenCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
    218220      this.includeChildrenCheckBox.Location = new System.Drawing.Point(94, 4);
    219221      this.includeChildrenCheckBox.Name = "includeChildrenCheckBox";
  • branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3/BubbleChartView.cs

    r12459 r12498  
    3737  [Content(typeof(RecursiveDataItem), false)]
    3838  public partial class BubbleChartView : ItemView {
    39 
    4039    private enum SizeDimension { Constant = 0 }
    4140    private enum AxisDimension { Index = 0 }
    4241
    43     private string xAxisValue;
    44     private string yAxisValue;
    45     private string sizeAxisValue;
    46 
    4742    private readonly Dictionary<RecursiveDataItem, int> itemToIndexMapping = new Dictionary<RecursiveDataItem, int>();
    4843    private readonly Dictionary<string, Dictionary<object, double>> categoricalMapping = new Dictionary<string, Dictionary<object, double>>();
     44
     45    private string XAxisValue { get { return (string)xAxisComboBox.SelectedItem; } }
     46    private string YAxisValue { get { return (string)yAxisComboBox.SelectedItem; } }
     47    private string SizeAxisValue { get { return (string)sizeComboBox.SelectedItem; } }
    4948
    5049    public new RecursiveDataItem Content {
     
    7473
    7574    #region Tree Queries
    76 
    7775    private IEnumerable<RecursiveDataItem> GetAvailableItems() {
    7876      return IterateCheckedNodes()
     
    117115      int level = (int)levelNumericUpDown.Value;
    118116      bool includeChildren = includeChildrenCheckBox.Checked;
    119       //treeView.BeginUpdate();
    120       foreach (var node in IterateAllNodes())
    121         node.Checked = includeChildren ? node.Level >= level : node.Level == level;
    122       //treeView.EndUpdate();
     117      foreach (var node in IterateAllNodes()) {
     118        bool @checked = includeChildren ? node.Level >= level : node.Level == level;
     119        if (node.Checked != @checked)
     120          node.Checked = @checked;
     121      }
    123122    }
    124123
     
    142141        sizeComboBox.Items.AddRange(additionalSizeDimension);
    143142        sizeComboBox.Items.AddRange(axisNames);
    144         sizeComboBox.SelectedItem = SizeDimension.Constant.ToString();
    145143
    146144        bool changed = false;
     
    156154          sizeComboBox.SelectedItem = selectedSizeAxis;
    157155          changed = true;
    158         }
     156        } else sizeComboBox.SelectedItem = SizeDimension.Constant.ToString();
    159157        if (changed) {
    160158          UpdateDataPoints();
    161           //UpdateAxisLabels();
     159          UpdateAxisLabels();
    162160        }
    163161      }
     
    171169      RebuildInverseIndex();
    172170
    173       chart.ChartAreas[0].AxisX.IsMarginVisible = xAxisValue != AxisDimension.Index.ToString();
    174       chart.ChartAreas[0].AxisY.IsMarginVisible = yAxisValue != AxisDimension.Index.ToString();
     171      chart.ChartAreas[0].AxisX.IsMarginVisible = XAxisValue != AxisDimension.Index.ToString();
     172      chart.ChartAreas[0].AxisY.IsMarginVisible = YAxisValue != AxisDimension.Index.ToString();
    175173
    176174      if (Content != null) {
    177175        var items = GetAvailableItems();
    178176        foreach (var item in items) {
    179           var x = GetValue(item, xAxisValue);
    180           var y = GetValue(item, yAxisValue);
    181           var s = GetValue(item, sizeAxisValue);
     177          var x = GetValue(item, XAxisValue);
     178          var y = GetValue(item, YAxisValue);
     179          var s = GetValue(item, SizeAxisValue);
    182180          if (x.HasValue && y.HasValue && s.HasValue) {
    183181            var dataPoint = new DataPoint(x.Value, new[] { y.Value, s.Value });
     
    267265
    268266    private void UpdateAxisLabels() {
    269       return;
    270267      Axis xAxis = chart.ChartAreas[0].AxisX;
    271268      Axis yAxis = chart.ChartAreas[0].AxisY;
    272269      //mkommend: combobox.SelectedIndex could not be used as this changes during hovering over possible values
    273       var xSAxisSelected = xAxisValue == null ? null : (string)xAxisComboBox.SelectedItem;
    274       var ySAxisSelected = yAxisValue == null ? null : (string)yAxisComboBox.SelectedItem;
     270      var xSAxisSelected = XAxisValue == null ? null : (string)xAxisComboBox.SelectedItem;
     271      var ySAxisSelected = YAxisValue == null ? null : (string)yAxisComboBox.SelectedItem;
    275272      SetCustomAxisLabels(xAxis, xSAxisSelected);
    276273      SetCustomAxisLabels(yAxis, ySAxisSelected);
    277       if (xAxisValue != null)
    278         xAxis.Title = xAxisValue;
    279       if (yAxisValue != null)
    280         yAxis.Title = yAxisValue;
     274      if (XAxisValue != null)
     275        xAxis.Title = XAxisValue;
     276      if (YAxisValue != null)
     277        yAxis.Title = YAxisValue;
    281278    }
    282279    private void chart_AxisViewChanged(object sender, System.Windows.Forms.DataVisualization.Charting.ViewEventArgs e) {
     
    285282    private void SetCustomAxisLabels(Axis axis, string key) {
    286283      axis.CustomLabels.Clear();
    287       if (categoricalMapping.ContainsKey(key)) {
     284      if (key != null && categoricalMapping.ContainsKey(key)) {
    288285        foreach (var pair in categoricalMapping[key]) {
    289286          string labelText = pair.Key.ToString();
     
    298295          axis.CustomLabels.Add(label);
    299296        }
    300       } else if (key != null && Content.Data[key] is TimeSpanValue) {
     297      } else if (false && key != null && Content.Data[key] is TimeSpanValue) { // TODO
    301298        chart.ChartAreas[0].RecalculateAxesScale();
    302299        for (double i = axis.Minimum; i <= axis.Maximum; i += axis.LabelStyle.Interval) {
     
    328325    private void treeView_AfterCheck(object sender, TreeViewEventArgs e) {
    329326      UpdateComboBoxes();
    330       //UpdateDataPoints();
     327      UpdateDataPoints();
    331328    }
    332329    private void treeView_AfterSelect(object sender, TreeViewEventArgs e) {
     
    337334
    338335    private void axisComboBox_SelectedValueChanged(object sender, EventArgs e) {
    339       bool axisSelected = xAxisComboBox.SelectedIndex != -1 && yAxisComboBox.SelectedIndex != -1;
    340 
    341       xAxisValue = (string)xAxisComboBox.SelectedItem;
    342       yAxisValue = (string)yAxisComboBox.SelectedItem;
    343       sizeAxisValue = (string)sizeComboBox.SelectedItem;
    344 
    345336      UpdateDataPoints();
    346337      UpdateAxisLabels();
     
    359350
    360351    #region Helpers
    361 
    362352    private IEnumerable<TreeNode> IterateAllNodes() {
    363353      return Collect(treeView.Nodes);
     
    373363      }
    374364    }
     365
     366    private void BeginUpdateComboBoxes() {
     367      xAxisComboBox.BeginUpdate();
     368      yAxisComboBox.BeginUpdate();
     369      sizeComboBox.BeginUpdate();
     370    }
     371    private void EndUpdateComboBoxes() {
     372      xAxisComboBox.EndUpdate();
     373      yAxisComboBox.EndUpdate();
     374      sizeComboBox.EndUpdate();
     375    }
    375376    #endregion
    376377  }
  • branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3/RecursiveDataItem.cs

    r12450 r12498  
    7171    }
    7272    IEnumerator IEnumerable.GetEnumerator() {
    73       throw new NotImplementedException();
     73      return data.GetEnumerator();
    7474    }
    7575
Note: See TracChangeset for help on using the changeset viewer.