Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/13/17 12:55:06 (8 years ago)
Author:
abeham
Message:

#2701: Updated branch to trunk

Location:
branches/MemPRAlgorithm
Files:
12 edited
4 copied

Legend:

Unmodified
Added
Removed
  • branches/MemPRAlgorithm

  • branches/MemPRAlgorithm/HeuristicLab.Analysis.Views

  • branches/MemPRAlgorithm/HeuristicLab.Analysis.Views/3.3/DataRowVisualPropertiesControl.Designer.cs

    r14185 r14562  
    5454      this.label3 = new System.Windows.Forms.Label();
    5555      this.commonGroupBox = new System.Windows.Forms.GroupBox();
     56      this.isVisibleInLegendCheckBox = new System.Windows.Forms.CheckBox();
     57      this.label10 = new System.Windows.Forms.Label();
    5658      this.displayNameTextBox = new System.Windows.Forms.TextBox();
    5759      this.axisGroupBox = new System.Windows.Forms.GroupBox();
     60      this.panel2 = new System.Windows.Forms.Panel();
    5861      this.yAxisSecondaryRadioButton = new System.Windows.Forms.RadioButton();
     62      this.yAxisPrimaryRadioButton = new System.Windows.Forms.RadioButton();
     63      this.panel1 = new System.Windows.Forms.Panel();
    5964      this.xAxisPrimaryRadioButton = new System.Windows.Forms.RadioButton();
    60       this.yAxisPrimaryRadioButton = new System.Windows.Forms.RadioButton();
     65      this.xAxisSecondaryRadioButton = new System.Windows.Forms.RadioButton();
    6166      this.label5 = new System.Windows.Forms.Label();
    62       this.xAxisSecondaryRadioButton = new System.Windows.Forms.RadioButton();
    6367      this.label6 = new System.Windows.Forms.Label();
    6468      this.label9 = new System.Windows.Forms.Label();
     
    7276      this.lineStyleComboBox = new System.Windows.Forms.ComboBox();
    7377      this.label8 = new System.Windows.Forms.Label();
    74       this.panel1 = new System.Windows.Forms.Panel();
    75       this.panel2 = new System.Windows.Forms.Panel();
    7678      ((System.ComponentModel.ISupportInitialize)(this.binsNumericUpDown)).BeginInit();
    7779      this.commonGroupBox.SuspendLayout();
    7880      this.axisGroupBox.SuspendLayout();
     81      this.panel2.SuspendLayout();
     82      this.panel1.SuspendLayout();
    7983      this.histoGramGroupBox.SuspendLayout();
    8084      this.lineChartGroupBox.SuspendLayout();
    8185      ((System.ComponentModel.ISupportInitialize)(this.lineWidthNumericUpDown)).BeginInit();
    82       this.panel1.SuspendLayout();
    83       this.panel2.SuspendLayout();
    8486      this.SuspendLayout();
    8587      //
     
    9092      this.chartTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    9193      this.chartTypeComboBox.FormattingEnabled = true;
    92       this.chartTypeComboBox.Location = new System.Drawing.Point(57, 45);
     94      this.chartTypeComboBox.Location = new System.Drawing.Point(102, 45);
    9395      this.chartTypeComboBox.Name = "chartTypeComboBox";
    94       this.chartTypeComboBox.Size = new System.Drawing.Size(264, 21);
     96      this.chartTypeComboBox.Size = new System.Drawing.Size(219, 21);
    9597      this.chartTypeComboBox.TabIndex = 3;
    9698      this.chartTypeComboBox.SelectedValueChanged += new System.EventHandler(this.chartTypeComboBox_SelectedValueChanged);
     
    103105      //
    104106      this.colorButton.BackColor = System.Drawing.SystemColors.Control;
    105       this.colorButton.Location = new System.Drawing.Point(56, 72);
     107      this.colorButton.Location = new System.Drawing.Point(102, 72);
    106108      this.colorButton.Name = "colorButton";
    107109      this.colorButton.Size = new System.Drawing.Size(23, 23);
     
    172174      this.commonGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    173175            | System.Windows.Forms.AnchorStyles.Right)));
     176      this.commonGroupBox.Controls.Add(this.isVisibleInLegendCheckBox);
     177      this.commonGroupBox.Controls.Add(this.label10);
    174178      this.commonGroupBox.Controls.Add(this.displayNameTextBox);
    175179      this.commonGroupBox.Controls.Add(this.axisGroupBox);
     
    181185      this.commonGroupBox.Location = new System.Drawing.Point(0, 0);
    182186      this.commonGroupBox.Name = "commonGroupBox";
    183       this.commonGroupBox.Size = new System.Drawing.Size(327, 174);
     187      this.commonGroupBox.Size = new System.Drawing.Size(327, 199);
    184188      this.commonGroupBox.TabIndex = 0;
    185189      this.commonGroupBox.TabStop = false;
    186190      this.commonGroupBox.Text = "Common";
    187191      //
     192      // isVisibleInLegendCheckBox
     193      //
     194      this.isVisibleInLegendCheckBox.AutoSize = true;
     195      this.isVisibleInLegendCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
     196      this.isVisibleInLegendCheckBox.Location = new System.Drawing.Point(102, 104);
     197      this.isVisibleInLegendCheckBox.Name = "isVisibleInLegendCheckBox";
     198      this.isVisibleInLegendCheckBox.Size = new System.Drawing.Size(15, 14);
     199      this.isVisibleInLegendCheckBox.TabIndex = 8;
     200      this.isVisibleInLegendCheckBox.UseVisualStyleBackColor = true;
     201      this.isVisibleInLegendCheckBox.CheckedChanged += new System.EventHandler(this.isVisibleInLegendCheckBox_CheckedChanged);
     202      //
     203      // label10
     204      //
     205      this.label10.AutoSize = true;
     206      this.label10.Location = new System.Drawing.Point(6, 104);
     207      this.label10.Name = "label10";
     208      this.label10.Size = new System.Drawing.Size(90, 13);
     209      this.label10.TabIndex = 7;
     210      this.label10.Text = "&Visible in Legend:";
     211      //
    188212      // displayNameTextBox
    189213      //
    190214      this.displayNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    191215            | System.Windows.Forms.AnchorStyles.Right)));
    192       this.displayNameTextBox.Location = new System.Drawing.Point(57, 19);
     216      this.displayNameTextBox.Location = new System.Drawing.Point(102, 19);
    193217      this.displayNameTextBox.Name = "displayNameTextBox";
    194       this.displayNameTextBox.Size = new System.Drawing.Size(264, 20);
     218      this.displayNameTextBox.Size = new System.Drawing.Size(219, 20);
    195219      this.displayNameTextBox.TabIndex = 1;
    196220      this.displayNameTextBox.Validated += new System.EventHandler(this.displayNameTextBox_Validated);
     
    205229      this.axisGroupBox.Controls.Add(this.label5);
    206230      this.axisGroupBox.Controls.Add(this.label6);
    207       this.axisGroupBox.Location = new System.Drawing.Point(6, 101);
     231      this.axisGroupBox.Location = new System.Drawing.Point(6, 126);
    208232      this.axisGroupBox.Name = "axisGroupBox";
    209233      this.axisGroupBox.Size = new System.Drawing.Size(315, 67);
     
    211235      this.axisGroupBox.TabStop = false;
    212236      this.axisGroupBox.Text = "Axes";
     237      //
     238      // panel2
     239      //
     240      this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     241            | System.Windows.Forms.AnchorStyles.Right)));
     242      this.panel2.Controls.Add(this.yAxisSecondaryRadioButton);
     243      this.panel2.Controls.Add(this.yAxisPrimaryRadioButton);
     244      this.panel2.Location = new System.Drawing.Point(51, 42);
     245      this.panel2.Name = "panel2";
     246      this.panel2.Size = new System.Drawing.Size(258, 17);
     247      this.panel2.TabIndex = 7;
    213248      //
    214249      // yAxisSecondaryRadioButton
     
    224259      this.yAxisSecondaryRadioButton.CheckedChanged += new System.EventHandler(this.yAxisRadioButton_CheckedChanged);
    225260      //
     261      // yAxisPrimaryRadioButton
     262      //
     263      this.yAxisPrimaryRadioButton.AutoSize = true;
     264      this.yAxisPrimaryRadioButton.Location = new System.Drawing.Point(0, 0);
     265      this.yAxisPrimaryRadioButton.Name = "yAxisPrimaryRadioButton";
     266      this.yAxisPrimaryRadioButton.Size = new System.Drawing.Size(59, 17);
     267      this.yAxisPrimaryRadioButton.TabIndex = 4;
     268      this.yAxisPrimaryRadioButton.TabStop = true;
     269      this.yAxisPrimaryRadioButton.Text = "&Primary";
     270      this.yAxisPrimaryRadioButton.UseVisualStyleBackColor = true;
     271      this.yAxisPrimaryRadioButton.CheckedChanged += new System.EventHandler(this.yAxisRadioButton_CheckedChanged);
     272      //
     273      // panel1
     274      //
     275      this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     276            | System.Windows.Forms.AnchorStyles.Right)));
     277      this.panel1.Controls.Add(this.xAxisPrimaryRadioButton);
     278      this.panel1.Controls.Add(this.xAxisSecondaryRadioButton);
     279      this.panel1.Location = new System.Drawing.Point(51, 19);
     280      this.panel1.Name = "panel1";
     281      this.panel1.Size = new System.Drawing.Size(258, 17);
     282      this.panel1.TabIndex = 6;
     283      //
    226284      // xAxisPrimaryRadioButton
    227285      //
     
    236294      this.xAxisPrimaryRadioButton.CheckedChanged += new System.EventHandler(this.xAxisRadioButton_CheckedChanged);
    237295      //
    238       // yAxisPrimaryRadioButton
    239       //
    240       this.yAxisPrimaryRadioButton.AutoSize = true;
    241       this.yAxisPrimaryRadioButton.Location = new System.Drawing.Point(0, 0);
    242       this.yAxisPrimaryRadioButton.Name = "yAxisPrimaryRadioButton";
    243       this.yAxisPrimaryRadioButton.Size = new System.Drawing.Size(59, 17);
    244       this.yAxisPrimaryRadioButton.TabIndex = 4;
    245       this.yAxisPrimaryRadioButton.TabStop = true;
    246       this.yAxisPrimaryRadioButton.Text = "&Primary";
    247       this.yAxisPrimaryRadioButton.UseVisualStyleBackColor = true;
    248       this.yAxisPrimaryRadioButton.CheckedChanged += new System.EventHandler(this.yAxisRadioButton_CheckedChanged);
    249       //
    250       // label5
    251       //
    252       this.label5.AutoSize = true;
    253       this.label5.Location = new System.Drawing.Point(6, 44);
    254       this.label5.Name = "label5";
    255       this.label5.Size = new System.Drawing.Size(39, 13);
    256       this.label5.TabIndex = 3;
    257       this.label5.Text = "&Y-Axis:";
    258       //
    259296      // xAxisSecondaryRadioButton
    260297      //
     
    269306      this.xAxisSecondaryRadioButton.CheckedChanged += new System.EventHandler(this.xAxisRadioButton_CheckedChanged);
    270307      //
     308      // label5
     309      //
     310      this.label5.AutoSize = true;
     311      this.label5.Location = new System.Drawing.Point(6, 44);
     312      this.label5.Name = "label5";
     313      this.label5.Size = new System.Drawing.Size(39, 13);
     314      this.label5.TabIndex = 3;
     315      this.label5.Text = "&Y-Axis:";
     316      //
    271317      // label6
    272318      //
     
    295341      this.histoGramGroupBox.Controls.Add(this.binsNumericUpDown);
    296342      this.histoGramGroupBox.Controls.Add(this.label3);
    297       this.histoGramGroupBox.Location = new System.Drawing.Point(0, 280);
     343      this.histoGramGroupBox.Location = new System.Drawing.Point(0, 305);
    298344      this.histoGramGroupBox.Name = "histoGramGroupBox";
    299345      this.histoGramGroupBox.Size = new System.Drawing.Size(327, 47);
     
    338384      this.lineChartGroupBox.Controls.Add(this.lineStyleComboBox);
    339385      this.lineChartGroupBox.Controls.Add(this.label8);
    340       this.lineChartGroupBox.Location = new System.Drawing.Point(0, 180);
     386      this.lineChartGroupBox.Location = new System.Drawing.Point(0, 205);
    341387      this.lineChartGroupBox.Name = "lineChartGroupBox";
    342388      this.lineChartGroupBox.Size = new System.Drawing.Size(327, 94);
     
    404450      this.label8.Text = "&Style:";
    405451      //
    406       // panel1
    407       //
    408       this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    409             | System.Windows.Forms.AnchorStyles.Right)));
    410       this.panel1.Controls.Add(this.xAxisPrimaryRadioButton);
    411       this.panel1.Controls.Add(this.xAxisSecondaryRadioButton);
    412       this.panel1.Location = new System.Drawing.Point(51, 19);
    413       this.panel1.Name = "panel1";
    414       this.panel1.Size = new System.Drawing.Size(258, 17);
    415       this.panel1.TabIndex = 6;
    416       //
    417       // panel2
    418       //
    419       this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    420             | System.Windows.Forms.AnchorStyles.Right)));
    421       this.panel2.Controls.Add(this.yAxisSecondaryRadioButton);
    422       this.panel2.Controls.Add(this.yAxisPrimaryRadioButton);
    423       this.panel2.Location = new System.Drawing.Point(51, 42);
    424       this.panel2.Name = "panel2";
    425       this.panel2.Size = new System.Drawing.Size(258, 17);
    426       this.panel2.TabIndex = 7;
    427       //
    428452      // DataRowVisualPropertiesControl
    429453      //
    430       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    431454      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    432455      this.Controls.Add(this.lineChartGroupBox);
     
    434457      this.Controls.Add(this.commonGroupBox);
    435458      this.Name = "DataRowVisualPropertiesControl";
    436       this.Size = new System.Drawing.Size(327, 331);
     459      this.Size = new System.Drawing.Size(327, 356);
    437460      ((System.ComponentModel.ISupportInitialize)(this.binsNumericUpDown)).EndInit();
    438461      this.commonGroupBox.ResumeLayout(false);
     
    440463      this.axisGroupBox.ResumeLayout(false);
    441464      this.axisGroupBox.PerformLayout();
     465      this.panel2.ResumeLayout(false);
     466      this.panel2.PerformLayout();
     467      this.panel1.ResumeLayout(false);
     468      this.panel1.PerformLayout();
    442469      this.histoGramGroupBox.ResumeLayout(false);
    443470      this.histoGramGroupBox.PerformLayout();
     
    445472      this.lineChartGroupBox.PerformLayout();
    446473      ((System.ComponentModel.ISupportInitialize)(this.lineWidthNumericUpDown)).EndInit();
    447       this.panel1.ResumeLayout(false);
    448       this.panel1.PerformLayout();
    449       this.panel2.ResumeLayout(false);
    450       this.panel2.PerformLayout();
    451474      this.ResumeLayout(false);
    452475
     
    484507    private System.Windows.Forms.Panel panel2;
    485508    private System.Windows.Forms.Panel panel1;
     509    private System.Windows.Forms.Label label10;
     510    private System.Windows.Forms.CheckBox isVisibleInLegendCheckBox;
    486511  }
    487512}
  • branches/MemPRAlgorithm/HeuristicLab.Analysis.Views/3.3/DataRowVisualPropertiesControl.cs

    r14185 r14562  
    9494          binsExactRadioButton.Checked = Content.ExactBins;
    9595          displayNameTextBox.Text = Content.DisplayName;
     96          isVisibleInLegendCheckBox.Checked = Content.IsVisibleInLegend;
    9697        }
    9798      } finally { SuppressEvents = false; }
     
    103104      lineChartGroupBox.Enabled = Content != null && Content.ChartType == DataRowVisualProperties.DataRowChartType.Line;
    104105      histoGramGroupBox.Enabled = Content != null && Content.ChartType == DataRowVisualProperties.DataRowChartType.Histogram;
     106      isVisibleInLegendCheckBox.Enabled = Content != null;
    105107    }
    106108
     
    188190      }
    189191    }
     192
     193    private void isVisibleInLegendCheckBox_CheckedChanged(object sender, EventArgs e) {
     194      if (!SuppressEvents && Content != null) {
     195        Content.IsVisibleInLegend = isVisibleInLegendCheckBox.Checked;
     196      }
     197    }
    190198    #endregion
    191199  }
  • branches/MemPRAlgorithm/HeuristicLab.Analysis.Views/3.3/DataTableView.Designer.cs

    r14185 r14562  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
    48       System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
    49       System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
    50       System.Windows.Forms.DataVisualization.Charting.Title title1 = new System.Windows.Forms.DataVisualization.Charting.Title();
    51       this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart();
     47      this.chart = new HeuristicLab.Analysis.Views.DataTableControl();
    5248      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    53       ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
    5449      this.SuspendLayout();
    5550      //
     
    7065                  | System.Windows.Forms.AnchorStyles.Left)
    7166                  | System.Windows.Forms.AnchorStyles.Right)));
    72       this.chart.BorderlineColor = System.Drawing.Color.Black;
    73       this.chart.BorderlineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
    74       chartArea1.AxisX.Minimum = 0D;
    75       chartArea1.CursorX.IsUserEnabled = true;
    76       chartArea1.CursorX.IsUserSelectionEnabled = true;
    77       chartArea1.CursorY.IsUserEnabled = true;
    78       chartArea1.CursorY.IsUserSelectionEnabled = true;
    79       chartArea1.Name = "Default";
    80       this.chart.ChartAreas.Add(chartArea1);
    81       legend1.Alignment = System.Drawing.StringAlignment.Center;
    82       legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
    83       legend1.Name = "Default";
    84       this.chart.Legends.Add(legend1);
    8567      this.chart.Location = new System.Drawing.Point(0, 26);
    8668      this.chart.Name = "chart";
    87       series1.ChartArea = "Default";
    88       series1.Legend = "Default";
    89       series1.Name = "Default";
    90       this.chart.Series.Add(series1);
    9169      this.chart.Size = new System.Drawing.Size(359, 248);
    9270      this.chart.TabIndex = 3;
    9371      this.chart.Text = "chart";
    94       title1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    95       title1.Name = "Default";
    96       title1.Text = "Title";
    97       this.chart.Titles.Add(title1);
    98       this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend);
    99       this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
    100       this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
    10172      //
    10273      // DataTableView
     
    11283      this.Controls.SetChildIndex(this.nameTextBox, 0);
    11384      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    114       ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
    11585      this.ResumeLayout(false);
    11686      this.PerformLayout();
    117 
    11887    }
    11988
    12089    #endregion
    12190
    122     protected HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart chart;
    123 
     91    protected HeuristicLab.Analysis.Views.DataTableControl chart;
    12492  }
    12593}
  • branches/MemPRAlgorithm/HeuristicLab.Analysis.Views/3.3/DataTableView.cs

    r14185 r14562  
    2020#endregion
    2121
    22 using HeuristicLab.Collections;
     22using System;
    2323using HeuristicLab.Core.Views;
    2424using HeuristicLab.MainForm;
    25 using System;
    26 using System.Collections.Generic;
    27 using System.Drawing;
    28 using System.Linq;
    29 using System.Windows.Forms;
    30 using System.Windows.Forms.DataVisualization.Charting;
    3125
    3226namespace HeuristicLab.Analysis.Views {
     
    3428  [Content(typeof(DataTable), true)]
    3529  public partial class DataTableView : NamedItemView, IConfigureableView {
    36     protected List<Series> invisibleSeries;
    37     protected Dictionary<IObservableList<double>, DataRow> valuesRowsTable;
    3830
    3931    public new DataTable Content {
     
    4436    public DataTableView() {
    4537      InitializeComponent();
    46       valuesRowsTable = new Dictionary<IObservableList<double>, DataRow>();
    47       invisibleSeries = new List<Series>();
    48       chart.CustomizeAllChartAreas();
    49       chart.ChartAreas[0].CursorX.Interval = 1;
    5038    }
    51 
    52     #region Event Handler Registration
    53     protected override void DeregisterContentEvents() {
    54       foreach (DataRow row in Content.Rows)
    55         DeregisterDataRowEvents(row);
    56       Content.VisualPropertiesChanged -= new EventHandler(Content_VisualPropertiesChanged);
    57       Content.Rows.ItemsAdded -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded);
    58       Content.Rows.ItemsRemoved -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsRemoved);
    59       Content.Rows.ItemsReplaced -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced);
    60       Content.Rows.CollectionReset -= new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset);
    61       base.DeregisterContentEvents();
    62     }
    63     protected override void RegisterContentEvents() {
    64       base.RegisterContentEvents();
    65       Content.VisualPropertiesChanged += new EventHandler(Content_VisualPropertiesChanged);
    66       Content.Rows.ItemsAdded += new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded);
    67       Content.Rows.ItemsRemoved += new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsRemoved);
    68       Content.Rows.ItemsReplaced += new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced);
    69       Content.Rows.CollectionReset += new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset);
    70     }
    71 
    72     protected virtual void RegisterDataRowEvents(DataRow row) {
    73       row.NameChanged += new EventHandler(Row_NameChanged);
    74       row.VisualPropertiesChanged += new EventHandler(Row_VisualPropertiesChanged);
    75       valuesRowsTable.Add(row.Values, row);
    76       row.Values.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsAdded);
    77       row.Values.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsRemoved);
    78       row.Values.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsReplaced);
    79       row.Values.ItemsMoved += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsMoved);
    80       row.Values.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_CollectionReset);
    81     }
    82     protected virtual void DeregisterDataRowEvents(DataRow row) {
    83       row.Values.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsAdded);
    84       row.Values.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsRemoved);
    85       row.Values.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsReplaced);
    86       row.Values.ItemsMoved -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsMoved);
    87       row.Values.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_CollectionReset);
    88       valuesRowsTable.Remove(row.Values);
    89       row.VisualPropertiesChanged -= new EventHandler(Row_VisualPropertiesChanged);
    90       row.NameChanged -= new EventHandler(Row_NameChanged);
    91     }
    92     #endregion
    9339
    9440    protected override void OnContentChanged() {
    9541      base.OnContentChanged();
    96       invisibleSeries.Clear();
    97       chart.Titles[0].Text = string.Empty;
    98       chart.ChartAreas[0].AxisX.Title = string.Empty;
    99       chart.ChartAreas[0].AxisY.Title = string.Empty;
    100       chart.ChartAreas[0].AxisY2.Title = string.Empty;
    101       chart.Series.Clear();
    102       if (Content != null) {
    103         chart.Titles[0].Text = Content.Name;
    104         AddDataRows(Content.Rows);
    105         ConfigureChartArea(chart.ChartAreas[0]);
    106         RecalculateAxesScale(chart.ChartAreas[0]);
    107       }
     42      chart.Content = Content;
    10843    }
    10944
     
    11348    }
    11449
    115     public void ShowConfiguration() {
    116       if (Content != null) {
    117         using (var dialog = new DataTableVisualPropertiesDialog(Content)) {
    118           dialog.ShowDialog(this);
    119         }
    120       } else MessageBox.Show("Nothing to configure.");
    121     }
    122     protected virtual void AddDataRows(IEnumerable<DataRow> rows) {
    123       foreach (var row in rows) {
    124         RegisterDataRowEvents(row);
    125         var series = new Series(row.Name);
    126         if (row.VisualProperties.DisplayName.Trim() != String.Empty) series.LegendText = row.VisualProperties.DisplayName;
    127         else series.LegendText = row.Name;
    128         ConfigureSeries(series, row);
    129         FillSeriesWithRowValues(series, row);
    130         chart.Series.Add(series);
    131       }
    132       ConfigureChartArea(chart.ChartAreas[0]);
    133       RecalculateAxesScale(chart.ChartAreas[0]);
    134       UpdateYCursorInterval();
    135     }
    136 
    137     protected virtual void RemoveDataRows(IEnumerable<DataRow> rows) {
    138       foreach (var row in rows) {
    139         DeregisterDataRowEvents(row);
    140         Series series = chart.Series[row.Name];
    141         chart.Series.Remove(series);
    142         if (invisibleSeries.Contains(series))
    143           invisibleSeries.Remove(series);
    144       }
    145       RecalculateAxesScale(chart.ChartAreas[0]);
    146     }
    147 
    148     private void ConfigureSeries(Series series, DataRow row) {
    149       RemoveCustomPropertyIfExists(series, "PointWidth");
    150       series.BorderWidth = 1;
    151       series.BorderDashStyle = ChartDashStyle.Solid;
    152       series.BorderColor = Color.Empty;
    153 
    154       if (row.VisualProperties.Color != Color.Empty)
    155         series.Color = row.VisualProperties.Color;
    156       else series.Color = Color.Empty;
    157       series.IsVisibleInLegend = row.VisualProperties.IsVisibleInLegend;
    158 
    159       switch (row.VisualProperties.ChartType) {
    160         case DataRowVisualProperties.DataRowChartType.Line:
    161           series.ChartType = SeriesChartType.FastLine;
    162           series.BorderWidth = row.VisualProperties.LineWidth;
    163           series.BorderDashStyle = ConvertLineStyle(row.VisualProperties.LineStyle);
    164           break;
    165         case DataRowVisualProperties.DataRowChartType.Bars:
    166           // Bar is incompatible with anything but Bar and StackedBar*
    167           if (!chart.Series.Any(x => x.ChartType != SeriesChartType.Bar && x.ChartType != SeriesChartType.StackedBar && x.ChartType != SeriesChartType.StackedBar100))
    168             series.ChartType = SeriesChartType.Bar;
    169           else {
    170             series.ChartType = SeriesChartType.FastPoint; //default
    171             row.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points;
    172           }
    173           break;
    174         case DataRowVisualProperties.DataRowChartType.Columns:
    175           series.ChartType = SeriesChartType.Column;
    176           break;
    177         case DataRowVisualProperties.DataRowChartType.Points:
    178           series.ChartType = SeriesChartType.FastPoint;
    179           break;
    180         case DataRowVisualProperties.DataRowChartType.Histogram:
    181           series.ChartType = SeriesChartType.Column;
    182           series.SetCustomProperty("PointWidth", "1");
    183           if (!series.Color.IsEmpty && series.Color.GetBrightness() < 0.25)
    184             series.BorderColor = Color.White;
    185           else series.BorderColor = Color.Black;
    186           break;
    187         case DataRowVisualProperties.DataRowChartType.StepLine:
    188           series.ChartType = SeriesChartType.StepLine;
    189           series.BorderWidth = row.VisualProperties.LineWidth;
    190           series.BorderDashStyle = ConvertLineStyle(row.VisualProperties.LineStyle);
    191           break;
    192         default:
    193           series.ChartType = SeriesChartType.FastPoint;
    194           break;
    195       }
    196       series.YAxisType = row.VisualProperties.SecondYAxis ? AxisType.Secondary : AxisType.Primary;
    197       series.XAxisType = row.VisualProperties.SecondXAxis ? AxisType.Secondary : AxisType.Primary;
    198       if (row.VisualProperties.DisplayName.Trim() != String.Empty) series.LegendText = row.VisualProperties.DisplayName;
    199       else series.LegendText = row.Name;
    200 
    201       string xAxisTitle = string.IsNullOrEmpty(Content.VisualProperties.XAxisTitle)
    202                       ? "X"
    203                       : Content.VisualProperties.XAxisTitle;
    204       string yAxisTitle = string.IsNullOrEmpty(Content.VisualProperties.YAxisTitle)
    205                             ? "Y"
    206                             : Content.VisualProperties.YAxisTitle;
    207       series.ToolTip =
    208         series.LegendText + Environment.NewLine +
    209         xAxisTitle + " = " + "#INDEX," + Environment.NewLine +
    210         yAxisTitle + " = " + "#VAL";
    211     }
    212 
    213     private void ConfigureChartArea(ChartArea area) {
    214       if (Content.VisualProperties.TitleFont != null) chart.Titles[0].Font = Content.VisualProperties.TitleFont;
    215       if (!Content.VisualProperties.TitleColor.IsEmpty) chart.Titles[0].ForeColor = Content.VisualProperties.TitleColor;
    216       chart.Titles[0].Text = Content.VisualProperties.Title;
    217 
    218       if (Content.VisualProperties.AxisTitleFont != null) area.AxisX.TitleFont = Content.VisualProperties.AxisTitleFont;
    219       if (!Content.VisualProperties.AxisTitleColor.IsEmpty) area.AxisX.TitleForeColor = Content.VisualProperties.AxisTitleColor;
    220       area.AxisX.Title = Content.VisualProperties.XAxisTitle;
    221 
    222       if (Content.VisualProperties.AxisTitleFont != null) area.AxisX2.TitleFont = Content.VisualProperties.AxisTitleFont;
    223       if (!Content.VisualProperties.AxisTitleColor.IsEmpty) area.AxisX2.TitleForeColor = Content.VisualProperties.AxisTitleColor;
    224       area.AxisX2.Title = Content.VisualProperties.SecondXAxisTitle;
    225 
    226       if (Content.VisualProperties.AxisTitleFont != null) area.AxisY.TitleFont = Content.VisualProperties.AxisTitleFont;
    227       if (!Content.VisualProperties.AxisTitleColor.IsEmpty) area.AxisY.TitleForeColor = Content.VisualProperties.AxisTitleColor;
    228       area.AxisY.Title = Content.VisualProperties.YAxisTitle;
    229 
    230       if (Content.VisualProperties.AxisTitleFont != null) area.AxisY2.TitleFont = Content.VisualProperties.AxisTitleFont;
    231       if (!Content.VisualProperties.AxisTitleColor.IsEmpty) area.AxisY2.TitleForeColor = Content.VisualProperties.AxisTitleColor;
    232       area.AxisY2.Title = Content.VisualProperties.SecondYAxisTitle;
    233 
    234       area.AxisX.IsLogarithmic = Content.VisualProperties.XAxisLogScale;
    235       area.AxisX2.IsLogarithmic = Content.VisualProperties.SecondXAxisLogScale;
    236       area.AxisY.IsLogarithmic = Content.VisualProperties.YAxisLogScale;
    237       area.AxisY2.IsLogarithmic = Content.VisualProperties.SecondYAxisLogScale;
    238     }
    239 
    240     private void RecalculateAxesScale(ChartArea area) {
    241       // Reset the axes bounds so that RecalculateAxesScale() will assign new bounds
    242       foreach (Axis a in area.Axes) {
    243         a.Minimum = double.NaN;
    244         a.Maximum = double.NaN;
    245       }
    246       area.RecalculateAxesScale();
    247       area.AxisX.IsMarginVisible = false;
    248       area.AxisX2.IsMarginVisible = false;
    249 
    250       if (!Content.VisualProperties.XAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.XAxisMinimumFixedValue)) area.AxisX.Minimum = Content.VisualProperties.XAxisMinimumFixedValue;
    251       if (!Content.VisualProperties.XAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.XAxisMaximumFixedValue)) area.AxisX.Maximum = Content.VisualProperties.XAxisMaximumFixedValue;
    252       if (!Content.VisualProperties.SecondXAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.SecondXAxisMinimumFixedValue)) area.AxisX2.Minimum = Content.VisualProperties.SecondXAxisMinimumFixedValue;
    253       if (!Content.VisualProperties.SecondXAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.SecondXAxisMaximumFixedValue)) area.AxisX2.Maximum = Content.VisualProperties.SecondXAxisMaximumFixedValue;
    254       if (!Content.VisualProperties.YAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.YAxisMinimumFixedValue)) area.AxisY.Minimum = Content.VisualProperties.YAxisMinimumFixedValue;
    255       if (!Content.VisualProperties.YAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.YAxisMaximumFixedValue)) area.AxisY.Maximum = Content.VisualProperties.YAxisMaximumFixedValue;
    256       if (!Content.VisualProperties.SecondYAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.SecondYAxisMinimumFixedValue)) area.AxisY2.Minimum = Content.VisualProperties.SecondYAxisMinimumFixedValue;
    257       if (!Content.VisualProperties.SecondYAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.SecondYAxisMaximumFixedValue)) area.AxisY2.Maximum = Content.VisualProperties.SecondYAxisMaximumFixedValue;
    258       if (area.AxisX.Minimum >= area.AxisX.Maximum) area.AxisX.Maximum = area.AxisX.Minimum + 1;
    259       if (area.AxisX2.Minimum >= area.AxisX2.Maximum) area.AxisX2.Maximum = area.AxisX2.Minimum + 1;
    260       if (area.AxisY.Minimum >= area.AxisY.Maximum) area.AxisY.Maximum = area.AxisY.Minimum + 1;
    261       if (area.AxisY2.Minimum >= area.AxisY2.Maximum) area.AxisY2.Maximum = area.AxisY2.Minimum + 1;
    262     }
    263 
    264     protected virtual void UpdateYCursorInterval() {
    265       double interestingValuesRange = (
    266         from series in chart.Series
    267         where series.Enabled
    268         let values = (from point in series.Points
    269                       where !point.IsEmpty
    270                       select point.YValues[0]).DefaultIfEmpty(1.0)
    271         let range = values.Max() - values.Min()
    272         where range > 0.0
    273         select range
    274         ).DefaultIfEmpty(1.0).Min();
    275 
    276       double digits = (int)Math.Log10(interestingValuesRange) - 3;
    277       double yZoomInterval = Math.Pow(10, digits);
    278       this.chart.ChartAreas[0].CursorY.Interval = yZoomInterval;
    279     }
    280 
    281     #region Event Handlers
    28250    #region Content Event Handlers
    28351    protected override void Content_NameChanged(object sender, EventArgs e) {
     
    28553        Invoke(new EventHandler(Content_NameChanged), sender, e);
    28654      else {
    287         chart.Titles[0].Text = Content.Name;
     55        Content.VisualProperties.Title = Content.Name;
    28856        base.Content_NameChanged(sender, e);
    289       }
    290     }
    291     private void Content_VisualPropertiesChanged(object sender, EventArgs e) {
    292       if (InvokeRequired)
    293         Invoke(new EventHandler(Content_VisualPropertiesChanged), sender, e);
    294       else {
    295         ConfigureChartArea(chart.ChartAreas[0]);
    296         RecalculateAxesScale(chart.ChartAreas[0]); // axes min/max could have changed
    297       }
    298     }
    299     #endregion
    300     #region Rows Event Handlers
    301     private void Rows_ItemsAdded(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
    302       if (InvokeRequired)
    303         Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded), sender, e);
    304       else {
    305         AddDataRows(e.Items);
    306       }
    307     }
    308     private void Rows_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
    309       if (InvokeRequired)
    310         Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsRemoved), sender, e);
    311       else {
    312         RemoveDataRows(e.Items);
    313       }
    314     }
    315     private void Rows_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
    316       if (InvokeRequired)
    317         Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced), sender, e);
    318       else {
    319         RemoveDataRows(e.OldItems);
    320         AddDataRows(e.Items);
    321       }
    322     }
    323     private void Rows_CollectionReset(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
    324       if (InvokeRequired)
    325         Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset), sender, e);
    326       else {
    327         RemoveDataRows(e.OldItems);
    328         AddDataRows(e.Items);
    329       }
    330     }
    331     #endregion
    332     #region Row Event Handlers
    333     private void Row_VisualPropertiesChanged(object sender, EventArgs e) {
    334       if (InvokeRequired)
    335         Invoke(new EventHandler(Row_VisualPropertiesChanged), sender, e);
    336       else {
    337         DataRow row = (DataRow)sender;
    338         Series series = chart.Series[row.Name];
    339         series.Points.Clear();
    340         ConfigureSeries(series, row);
    341         FillSeriesWithRowValues(series, row);
    342         RecalculateAxesScale(chart.ChartAreas[0]);
    343       }
    344     }
    345     private void Row_NameChanged(object sender, EventArgs e) {
    346       if (InvokeRequired)
    347         Invoke(new EventHandler(Row_NameChanged), sender, e);
    348       else {
    349         DataRow row = (DataRow)sender;
    350         chart.Series[row.Name].Name = row.Name;
    351       }
    352     }
    353     #endregion
    354     #region Values Event Handlers
    355     private void Values_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) {
    356       if (InvokeRequired)
    357         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsAdded), sender, e);
    358       else {
    359         DataRow row = null;
    360         valuesRowsTable.TryGetValue((IObservableList<double>)sender, out row);
    361         if (row != null) {
    362           Series rowSeries = chart.Series[row.Name];
    363           if (!invisibleSeries.Contains(rowSeries)) {
    364             rowSeries.Points.Clear();
    365             FillSeriesWithRowValues(rowSeries, row);
    366             RecalculateAxesScale(chart.ChartAreas[0]);
    367             UpdateYCursorInterval();
    368           }
    369         }
    370       }
    371     }
    372     private void Values_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) {
    373       if (InvokeRequired)
    374         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsRemoved), sender, e);
    375       else {
    376         DataRow row = null;
    377         valuesRowsTable.TryGetValue((IObservableList<double>)sender, out row);
    378         if (row != null) {
    379           Series rowSeries = chart.Series[row.Name];
    380           if (!invisibleSeries.Contains(rowSeries)) {
    381             rowSeries.Points.Clear();
    382             FillSeriesWithRowValues(rowSeries, row);
    383             RecalculateAxesScale(chart.ChartAreas[0]);
    384             UpdateYCursorInterval();
    385           }
    386         }
    387       }
    388     }
    389     private void Values_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) {
    390       if (InvokeRequired)
    391         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsReplaced), sender, e);
    392       else {
    393         DataRow row = null;
    394         valuesRowsTable.TryGetValue((IObservableList<double>)sender, out row);
    395         if (row != null) {
    396           Series rowSeries = chart.Series[row.Name];
    397           if (!invisibleSeries.Contains(rowSeries)) {
    398             if (row.VisualProperties.ChartType == DataRowVisualProperties.DataRowChartType.Histogram) {
    399               rowSeries.Points.Clear();
    400               FillSeriesWithRowValues(rowSeries, row);
    401             } else {
    402               foreach (IndexedItem<double> item in e.Items) {
    403                 if (IsInvalidValue(item.Value))
    404                   rowSeries.Points[item.Index].IsEmpty = true;
    405                 else {
    406                   rowSeries.Points[item.Index].YValues = new double[] { item.Value };
    407                   rowSeries.Points[item.Index].IsEmpty = false;
    408                 }
    409               }
    410             }
    411             RecalculateAxesScale(chart.ChartAreas[0]);
    412             UpdateYCursorInterval();
    413           }
    414         }
    415       }
    416     }
    417     private void Values_ItemsMoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) {
    418       if (InvokeRequired)
    419         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsMoved), sender, e);
    420       else {
    421         DataRow row = null;
    422         valuesRowsTable.TryGetValue((IObservableList<double>)sender, out row);
    423         if (row != null) {
    424           Series rowSeries = chart.Series[row.Name];
    425           if (!invisibleSeries.Contains(rowSeries)) {
    426             rowSeries.Points.Clear();
    427             FillSeriesWithRowValues(rowSeries, row);
    428             RecalculateAxesScale(chart.ChartAreas[0]);
    429             UpdateYCursorInterval();
    430           }
    431         }
    432       }
    433     }
    434 
    435     private void Values_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) {
    436       if (InvokeRequired)
    437         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_CollectionReset), sender, e);
    438       else {
    439         DataRow row = null;
    440         valuesRowsTable.TryGetValue((IObservableList<double>)sender, out row);
    441         if (row != null) {
    442           Series rowSeries = chart.Series[row.Name];
    443           if (!invisibleSeries.Contains(rowSeries)) {
    444             rowSeries.Points.Clear();
    445             FillSeriesWithRowValues(rowSeries, row);
    446             RecalculateAxesScale(chart.ChartAreas[0]);
    447             UpdateYCursorInterval();
    448           }
    449         }
    450       }
    451     }
    452     #endregion
    453     #endregion
    454 
    455     #region Chart Event Handlers
    456     private void chart_MouseDown(object sender, MouseEventArgs e) {
    457       HitTestResult result = chart.HitTest(e.X, e.Y);
    458       if (result.ChartElementType == ChartElementType.LegendItem) {
    459         ToggleSeriesVisible(result.Series);
    460       }
    461     }
    462     private void chart_MouseMove(object sender, MouseEventArgs e) {
    463       HitTestResult result = chart.HitTest(e.X, e.Y);
    464       if (result.ChartElementType == ChartElementType.LegendItem)
    465         this.Cursor = Cursors.Hand;
    466       else
    467         this.Cursor = Cursors.Default;
    468     }
    469     private void chart_CustomizeLegend(object sender, CustomizeLegendEventArgs e) {
    470       foreach (LegendItem legendItem in e.LegendItems) {
    471         var series = chart.Series[legendItem.SeriesName];
    472         if (series != null) {
    473           bool seriesIsInvisible = invisibleSeries.Contains(series);
    474           foreach (LegendCell cell in legendItem.Cells) {
    475             cell.ForeColor = seriesIsInvisible ? Color.Gray : Color.Black;
    476           }
    477         }
    47857      }
    47958    }
    48059    #endregion
    48160
    482     private void ToggleSeriesVisible(Series series) {
    483       if (!invisibleSeries.Contains(series)) {
    484         series.Points.Clear();
    485         invisibleSeries.Add(series);
    486       } else {
    487         invisibleSeries.Remove(series);
    488         if (Content != null) {
    489 
    490           var row = (from r in Content.Rows
    491                      where r.Name == series.Name
    492                      select r).Single();
    493           FillSeriesWithRowValues(series, row);
    494           this.chart.Legends[series.Legend].ForeColor = Color.Black;
    495           RecalculateAxesScale(chart.ChartAreas[0]);
    496           UpdateYCursorInterval();
    497         }
    498       }
     61    public void ShowConfiguration() {
     62      chart.ShowConfiguration();
    49963    }
    500 
    501     private void FillSeriesWithRowValues(Series series, DataRow row) {
    502       switch (row.VisualProperties.ChartType) {
    503         case DataRowVisualProperties.DataRowChartType.Histogram:
    504           CalculateHistogram(series, row);
    505           break;
    506         default: {
    507             bool yLogarithmic = series.YAxisType == AxisType.Primary
    508                                   ? Content.VisualProperties.YAxisLogScale
    509                                   : Content.VisualProperties.SecondYAxisLogScale;
    510             bool xLogarithmic = series.XAxisType == AxisType.Primary
    511                                   ? Content.VisualProperties.XAxisLogScale
    512                                   : Content.VisualProperties.SecondXAxisLogScale;
    513             for (int i = 0; i < row.Values.Count; i++) {
    514               var value = row.Values[i];
    515               var point = new DataPoint();
    516               point.XValue = row.VisualProperties.StartIndexZero && !xLogarithmic ? i : i + 1;
    517               if (IsInvalidValue(value) || (yLogarithmic && value <= 0))
    518                 point.IsEmpty = true;
    519               else
    520                 point.YValues = new double[] { value };
    521               series.Points.Add(point);
    522             }
    523           }
    524           break;
    525       }
    526     }
    527 
    528     protected virtual void CalculateHistogram(Series series, DataRow row) {
    529       series.Points.Clear();
    530       if (!row.Values.Any()) return;
    531       int bins = row.VisualProperties.Bins;
    532 
    533       double minValue = row.Values.Min();
    534       double maxValue = row.Values.Max();
    535       double intervalWidth = (maxValue - minValue) / bins;
    536       if (intervalWidth < 0) return;
    537       if (intervalWidth == 0) {
    538         series.Points.AddXY(minValue, row.Values.Count);
    539         return;
    540       }
    541 
    542       if (!row.VisualProperties.ExactBins) {
    543         intervalWidth = HumanRoundRange(intervalWidth);
    544         minValue = Math.Floor(minValue / intervalWidth) * intervalWidth;
    545         maxValue = Math.Ceiling(maxValue / intervalWidth) * intervalWidth;
    546       }
    547 
    548       double intervalCenter = intervalWidth / 2;
    549 
    550       double min = 0.0, max = 0.0;
    551       if (!Double.IsNaN(Content.VisualProperties.XAxisMinimumFixedValue) && !Content.VisualProperties.XAxisMinimumAuto)
    552         min = Content.VisualProperties.XAxisMinimumFixedValue;
    553       else min = minValue;
    554       if (!Double.IsNaN(Content.VisualProperties.XAxisMaximumFixedValue) && !Content.VisualProperties.XAxisMaximumAuto)
    555         max = Content.VisualProperties.XAxisMaximumFixedValue;
    556       else max = maxValue + intervalWidth;
    557 
    558       double axisInterval = intervalWidth / row.VisualProperties.ScaleFactor;
    559 
    560       var area = chart.ChartAreas[0];
    561       area.AxisX.Interval = axisInterval;
    562 
    563       series.SetCustomProperty("PointWidth", "1"); // 0.8 is the default value
    564 
    565       // get the range or intervals which define the grouping of the frequency values
    566       var doubleRange = DoubleRange(min, max, intervalWidth).Skip(1).ToList();
    567 
    568       // aggregate the row values by unique key and frequency value
    569       var valueFrequencies = (from v in row.Values
    570                               where !IsInvalidValue(v)
    571                               orderby v
    572                               group v by v into g
    573                               select new Tuple<double, double>(g.First(), g.Count())).ToList();
    574 
    575       // shift the chart to the left so the bars are placed on the intervals
    576       if (valueFrequencies.First().Item1 < doubleRange.First())
    577         series.Points.Add(new DataPoint(min - intervalWidth, 0));
    578 
    579       // add data points
    580       int j = 0;
    581       foreach (var d in doubleRange) {
    582         double sum = 0.0;
    583         // sum the frequency values that fall within the same interval
    584         while (j < valueFrequencies.Count && valueFrequencies[j].Item1 < d) {
    585           sum += valueFrequencies[j].Item2;
    586           ++j;
    587         }
    588         string xAxisTitle = string.IsNullOrEmpty(Content.VisualProperties.XAxisTitle)
    589                               ? "X"
    590                               : Content.VisualProperties.XAxisTitle;
    591         string yAxisTitle = string.IsNullOrEmpty(Content.VisualProperties.YAxisTitle)
    592                               ? "Y"
    593                               : Content.VisualProperties.YAxisTitle;
    594         series.Points.Add(new DataPoint(d - intervalCenter, sum) {
    595           ToolTip =
    596             xAxisTitle + ": [" + (d - intervalWidth) + "-" + d + ")" + Environment.NewLine +
    597             yAxisTitle + ": " + sum
    598         });
    599       }
    600     }
    601 
    602     #region Helpers
    603     public static IEnumerable<double> DoubleRange(double min, double max, double step) {
    604       double i;
    605       for (i = min; i <= max; i += step)
    606         yield return i;
    607 
    608       if (i != max + step)
    609         yield return i;
    610     }
    611 
    612     protected void RemoveCustomPropertyIfExists(Series series, string property) {
    613       if (series.IsCustomPropertySet(property)) series.DeleteCustomProperty(property);
    614     }
    615 
    616     private double HumanRoundRange(double range) {
    617       double base10 = Math.Pow(10.0, Math.Floor(Math.Log10(range)));
    618       double rounding = range / base10;
    619       if (rounding <= 1.5) rounding = 1;
    620       else if (rounding <= 2.25) rounding = 2;
    621       else if (rounding <= 3.75) rounding = 2.5;
    622       else if (rounding <= 7.5) rounding = 5;
    623       else rounding = 10;
    624       return rounding * base10;
    625     }
    626 
    627     private double HumanRoundMax(double max) {
    628       double base10;
    629       if (max > 0) base10 = Math.Pow(10.0, Math.Floor(Math.Log10(max)));
    630       else base10 = Math.Pow(10.0, Math.Ceiling(Math.Log10(-max)));
    631       double rounding = (max > 0) ? base10 : -base10;
    632       while (rounding < max) rounding += base10;
    633       return rounding;
    634     }
    635 
    636     private ChartDashStyle ConvertLineStyle(DataRowVisualProperties.DataRowLineStyle dataRowLineStyle) {
    637       switch (dataRowLineStyle) {
    638         case DataRowVisualProperties.DataRowLineStyle.Dash:
    639           return ChartDashStyle.Dash;
    640         case DataRowVisualProperties.DataRowLineStyle.DashDot:
    641           return ChartDashStyle.DashDot;
    642         case DataRowVisualProperties.DataRowLineStyle.DashDotDot:
    643           return ChartDashStyle.DashDotDot;
    644         case DataRowVisualProperties.DataRowLineStyle.Dot:
    645           return ChartDashStyle.Dot;
    646         case DataRowVisualProperties.DataRowLineStyle.NotSet:
    647           return ChartDashStyle.NotSet;
    648         case DataRowVisualProperties.DataRowLineStyle.Solid:
    649           return ChartDashStyle.Solid;
    650         default:
    651           return ChartDashStyle.NotSet;
    652       }
    653     }
    654 
    655     protected static bool IsInvalidValue(double x) {
    656       return double.IsNaN(x) || x < (double)decimal.MinValue || x > (double)decimal.MaxValue;
    657     }
    658     #endregion
    65964  }
    66065}
  • branches/MemPRAlgorithm/HeuristicLab.Analysis.Views/3.3/HeuristicLab.Analysis.Views-3.3.csproj

    r14208 r14562  
    105105  </PropertyGroup>
    106106  <ItemGroup>
     107    <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     108      <HintPath>..\..\bin\ALGLIB-3.7.0.dll</HintPath>
     109      <Private>False</Private>
     110    </Reference>
    107111    <Reference Include="System" />
    108112    <Reference Include="System.Core">
     
    122126  </ItemGroup>
    123127  <ItemGroup>
     128    <Compile Include="DataTableControl.cs">
     129      <SubType>UserControl</SubType>
     130    </Compile>
     131    <Compile Include="DataTableControl.Designer.cs">
     132      <DependentUpon>DataTableControl.cs</DependentUpon>
     133    </Compile>
    124134    <Compile Include="IndexedDataTableView.cs">
    125135      <SubType>UserControl</SubType>
     
    127137    <Compile Include="IndexedDataTableView.Designer.cs">
    128138      <DependentUpon>IndexedDataTableView.cs</DependentUpon>
     139    </Compile>
     140    <Compile Include="ScatterPlotControl.cs">
     141      <SubType>UserControl</SubType>
     142    </Compile>
     143    <Compile Include="ScatterPlotControl.Designer.cs">
     144      <DependentUpon>ScatterPlotControl.cs</DependentUpon>
    129145    </Compile>
    130146    <Compile Include="ScatterPlotVisualPropertiesDialog.cs">
  • branches/MemPRAlgorithm/HeuristicLab.Analysis.Views/3.3/Plugin.cs.frame

    r14195 r14562  
    2828  [Plugin("HeuristicLab.Analysis.Views", "3.3.14.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Analysis.Views-3.3.dll", PluginFileType.Assembly)]
     30  [PluginDependency("HeuristicLab.ALGLIB", "3.7.0")]
    3031  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    3132  [PluginDependency("HeuristicLab.Collections", "3.3")]
  • branches/MemPRAlgorithm/HeuristicLab.Analysis.Views/3.3/ScatterPlotDataRowVisualPropertiesControl.Designer.cs

    r14185 r14562  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
    4748      this.pointStyleComboBox = new System.Windows.Forms.ComboBox();
    4849      this.colorDialog = new System.Windows.Forms.ColorDialog();
     
    5657      this.label9 = new System.Windows.Forms.Label();
    5758      this.label7 = new System.Windows.Forms.Label();
     59      this.label4 = new System.Windows.Forms.Label();
     60      this.regressionTypeComboBox = new System.Windows.Forms.ComboBox();
     61      this.regressionGroupBox = new System.Windows.Forms.GroupBox();
     62      this.isRegressionVisibleInLegendCheckBox = new System.Windows.Forms.CheckBox();
     63      this.polynomialRegressionOrderNumericUpDown = new System.Windows.Forms.NumericUpDown();
     64      this.orderLabel = new System.Windows.Forms.Label();
     65      this.regressionLegendTextBox = new System.Windows.Forms.TextBox();
     66      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    5867      ((System.ComponentModel.ISupportInitialize)(this.pointSizeNumericUpDown)).BeginInit();
     68      this.regressionGroupBox.SuspendLayout();
     69      ((System.ComponentModel.ISupportInitialize)(this.polynomialRegressionOrderNumericUpDown)).BeginInit();
    5970      this.SuspendLayout();
    6071      //
     
    171182      this.label7.Text = "&Visible in Legend:";
    172183      //
     184      // label4
     185      //
     186      this.label4.AutoSize = true;
     187      this.label4.Location = new System.Drawing.Point(6, 22);
     188      this.label4.Name = "label4";
     189      this.label4.Size = new System.Drawing.Size(34, 13);
     190      this.label4.TabIndex = 7;
     191      this.label4.Text = "Type:";
     192      //
     193      // regressionTypeComboBox
     194      //
     195      this.regressionTypeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     196            | System.Windows.Forms.AnchorStyles.Right)));
     197      this.regressionTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     198      this.regressionTypeComboBox.FormattingEnabled = true;
     199      this.regressionTypeComboBox.Location = new System.Drawing.Point(93, 19);
     200      this.regressionTypeComboBox.Name = "regressionTypeComboBox";
     201      this.regressionTypeComboBox.Size = new System.Drawing.Size(147, 21);
     202      this.regressionTypeComboBox.TabIndex = 8;
     203      this.regressionTypeComboBox.SelectedValueChanged += new System.EventHandler(this.regressionTypeComboBox_SelectedValueChanged);
     204      //
     205      // regressionGroupBox
     206      //
     207      this.regressionGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     208            | System.Windows.Forms.AnchorStyles.Right)));
     209      this.regressionGroupBox.Controls.Add(this.isRegressionVisibleInLegendCheckBox);
     210      this.regressionGroupBox.Controls.Add(this.regressionTypeComboBox);
     211      this.regressionGroupBox.Controls.Add(this.polynomialRegressionOrderNumericUpDown);
     212      this.regressionGroupBox.Controls.Add(this.orderLabel);
     213      this.regressionGroupBox.Controls.Add(this.regressionLegendTextBox);
     214      this.regressionGroupBox.Controls.Add(this.label4);
     215      this.regressionGroupBox.Location = new System.Drawing.Point(3, 136);
     216      this.regressionGroupBox.Name = "regressionGroupBox";
     217      this.regressionGroupBox.Size = new System.Drawing.Size(336, 74);
     218      this.regressionGroupBox.TabIndex = 9;
     219      this.regressionGroupBox.TabStop = false;
     220      this.regressionGroupBox.Text = "&Regression";
     221      //
     222      // isRegressionVisibleInLegendCheckBox
     223      //
     224      this.isRegressionVisibleInLegendCheckBox.AutoSize = true;
     225      this.isRegressionVisibleInLegendCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
     226      this.isRegressionVisibleInLegendCheckBox.Location = new System.Drawing.Point(6, 48);
     227      this.isRegressionVisibleInLegendCheckBox.Name = "isRegressionVisibleInLegendCheckBox";
     228      this.isRegressionVisibleInLegendCheckBox.Size = new System.Drawing.Size(68, 17);
     229      this.isRegressionVisibleInLegendCheckBox.TabIndex = 13;
     230      this.isRegressionVisibleInLegendCheckBox.Text = "Legend: ";
     231      this.isRegressionVisibleInLegendCheckBox.UseVisualStyleBackColor = true;
     232      this.isRegressionVisibleInLegendCheckBox.CheckedChanged += new System.EventHandler(this.isRegressionVisibleInLegendCheckBox_CheckedChanged);
     233      //
     234      // polynomialRegressionOrderNumericUpDown
     235      //
     236      this.polynomialRegressionOrderNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     237      this.polynomialRegressionOrderNumericUpDown.Location = new System.Drawing.Point(285, 20);
     238      this.polynomialRegressionOrderNumericUpDown.Margin = new System.Windows.Forms.Padding(9, 3, 3, 3);
     239      this.polynomialRegressionOrderNumericUpDown.Maximum = new decimal(new int[] {
     240            6,
     241            0,
     242            0,
     243            0});
     244      this.polynomialRegressionOrderNumericUpDown.Minimum = new decimal(new int[] {
     245            2,
     246            0,
     247            0,
     248            0});
     249      this.polynomialRegressionOrderNumericUpDown.Name = "polynomialRegressionOrderNumericUpDown";
     250      this.polynomialRegressionOrderNumericUpDown.Size = new System.Drawing.Size(45, 20);
     251      this.polynomialRegressionOrderNumericUpDown.TabIndex = 11;
     252      this.toolTip.SetToolTip(this.polynomialRegressionOrderNumericUpDown, "Order only available for Polynomial");
     253      this.polynomialRegressionOrderNumericUpDown.Value = new decimal(new int[] {
     254            2,
     255            0,
     256            0,
     257            0});
     258      this.polynomialRegressionOrderNumericUpDown.ValueChanged += new System.EventHandler(this.polynomialRegressionOrderNumericUpDown_ValueChanged);
     259      //
     260      // orderLabel
     261      //
     262      this.orderLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     263      this.orderLabel.AutoSize = true;
     264      this.orderLabel.Location = new System.Drawing.Point(246, 22);
     265      this.orderLabel.Name = "orderLabel";
     266      this.orderLabel.Size = new System.Drawing.Size(36, 13);
     267      this.orderLabel.TabIndex = 12;
     268      this.orderLabel.Text = "Order:";
     269      //
     270      // regressionLegendTextBox
     271      //
     272      this.regressionLegendTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     273            | System.Windows.Forms.AnchorStyles.Right)));
     274      this.regressionLegendTextBox.Location = new System.Drawing.Point(93, 46);
     275      this.regressionLegendTextBox.Name = "regressionLegendTextBox";
     276      this.regressionLegendTextBox.Size = new System.Drawing.Size(237, 20);
     277      this.regressionLegendTextBox.TabIndex = 10;
     278      this.regressionLegendTextBox.Validated += new System.EventHandler(this.regressionLegendTextBox_Validated);
     279      //
    173280      // ScatterPlotDataRowVisualPropertiesControl
    174281      //
    175282      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     283      this.Controls.Add(this.regressionGroupBox);
    176284      this.Controls.Add(this.pointSizeNumericUpDown);
    177285      this.Controls.Add(this.isVisibleInLegendCheckBox);
     
    185293      this.Controls.Add(this.colorButton);
    186294      this.Name = "ScatterPlotDataRowVisualPropertiesControl";
    187       this.Size = new System.Drawing.Size(342, 135);
     295      this.Size = new System.Drawing.Size(342, 215);
    188296      ((System.ComponentModel.ISupportInitialize)(this.pointSizeNumericUpDown)).EndInit();
     297      this.regressionGroupBox.ResumeLayout(false);
     298      this.regressionGroupBox.PerformLayout();
     299      ((System.ComponentModel.ISupportInitialize)(this.polynomialRegressionOrderNumericUpDown)).EndInit();
    189300      this.ResumeLayout(false);
    190301      this.PerformLayout();
     
    205316    private System.Windows.Forms.Label label9;
    206317    private System.Windows.Forms.Label label3;
     318    private System.Windows.Forms.Label label4;
     319    private System.Windows.Forms.ComboBox regressionTypeComboBox;
     320    private System.Windows.Forms.GroupBox regressionGroupBox;
     321    private System.Windows.Forms.TextBox regressionLegendTextBox;
     322    private System.Windows.Forms.NumericUpDown polynomialRegressionOrderNumericUpDown;
     323    private System.Windows.Forms.Label orderLabel;
     324    private System.Windows.Forms.ToolTip toolTip;
     325    private System.Windows.Forms.CheckBox isRegressionVisibleInLegendCheckBox;
    207326  }
    208327}
  • branches/MemPRAlgorithm/HeuristicLab.Analysis.Views/3.3/ScatterPlotDataRowVisualPropertiesControl.cs

    r14185 r14562  
    4444      InitializeComponent();
    4545      pointStyleComboBox.DataSource = Enum.GetValues(typeof(ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle));
     46      regressionTypeComboBox.DataSource = Enum.GetValues(typeof(ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType));
    4647      SetEnabledStateOfControls();
    4748    }
     
    5758          pointSizeNumericUpDown.Value = 1;
    5859          displayNameTextBox.Text = String.Empty;
     60          regressionTypeComboBox.SelectedIndex = -1;
     61          polynomialRegressionOrderNumericUpDown.Value = 2;
     62          isRegressionVisibleInLegendCheckBox.Checked = false;
     63          regressionLegendTextBox.Text = string.Empty;
    5964        } else {
    6065          displayNameTextBox.Text = Content.DisplayName;
     
    6974          pointSizeNumericUpDown.Value = Content.PointSize;
    7075          isVisibleInLegendCheckBox.Checked = Content.IsVisibleInLegend;
     76          regressionTypeComboBox.SelectedItem = Content.RegressionType;
     77          polynomialRegressionOrderNumericUpDown.Value = Content.PolynomialRegressionOrder;
     78          isRegressionVisibleInLegendCheckBox.Checked = Content.IsRegressionVisibleInLegend;
     79          regressionLegendTextBox.Text = content.RegressionDisplayName;
    7180        }
    7281      }
     
    8291      pointSizeNumericUpDown.Enabled = Content != null;
    8392      displayNameTextBox.Enabled = Content != null;
     93      regressionTypeComboBox.Enabled = Content != null;
     94      polynomialRegressionOrderNumericUpDown.Enabled = Content != null && Content.RegressionType == ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType.Polynomial;
     95      orderLabel.Enabled = polynomialRegressionOrderNumericUpDown.Enabled;
     96      isRegressionVisibleInLegendCheckBox.Enabled = Content != null && Content.RegressionType != ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType.None;
     97      regressionLegendTextBox.Enabled = Content != null && Content.RegressionType != ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType.None;
    8498    }
    8599
     
    87101    private void pointStyleComboBox_SelectedValueChanged(object sender, EventArgs e) {
    88102      if (!SuppressEvents && Content != null) {
    89         ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle selected = (ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle)pointStyleComboBox.SelectedValue;
     103        var selected = (ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle)pointStyleComboBox.SelectedValue;
    90104        Content.PointStyle = selected;
    91105      }
     
    121135      }
    122136    }
     137
     138    private void regressionTypeComboBox_SelectedValueChanged(object sender, EventArgs e) {
     139      if (!SuppressEvents && Content != null) {
     140        var selected = (ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType)regressionTypeComboBox.SelectedValue;
     141        Content.RegressionType = selected;
     142        SetEnabledStateOfControls();
     143      }
     144    }
     145
     146    private void polynomialRegressionOrderNumericUpDown_ValueChanged(object sender, EventArgs e) {
     147      if (!SuppressEvents && Content != null) {
     148        Content.PolynomialRegressionOrder = (int)polynomialRegressionOrderNumericUpDown.Value;
     149      }
     150    }
     151
     152    private void isRegressionVisibleInLegendCheckBox_CheckedChanged(object sender, EventArgs e) {
     153      if (!SuppressEvents && Content != null) {
     154        Content.IsRegressionVisibleInLegend = isRegressionVisibleInLegendCheckBox.Checked;
     155      }
     156    }
     157
     158    private void regressionLegendTextBox_Validated(object sender, EventArgs e) {
     159      if (!SuppressEvents && Content != null) {
     160        Content.RegressionDisplayName = regressionLegendTextBox.Text;
     161      }
     162    }
    123163    #endregion
    124164  }
  • branches/MemPRAlgorithm/HeuristicLab.Analysis.Views/3.3/ScatterPlotView.Designer.cs

    r14185 r14562  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
    48       System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
    49       System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
    50       System.Windows.Forms.DataVisualization.Charting.Title title1 = new System.Windows.Forms.DataVisualization.Charting.Title();
    51       this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart();
     47      this.chart = new HeuristicLab.Analysis.Views.ScatterPlotControl();
    5248      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    53       ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
    5449      this.SuspendLayout();
    5550      //
     
    7065                  | System.Windows.Forms.AnchorStyles.Left)
    7166                  | System.Windows.Forms.AnchorStyles.Right)));
    72       this.chart.BorderlineColor = System.Drawing.Color.Black;
    73       this.chart.BorderlineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
    74       chartArea1.AxisX.Minimum = 0D;
    75       chartArea1.CursorX.IsUserEnabled = true;
    76       chartArea1.CursorX.IsUserSelectionEnabled = true;
    77       chartArea1.CursorY.IsUserEnabled = true;
    78       chartArea1.CursorY.IsUserSelectionEnabled = true;
    79       chartArea1.Name = "Default";
    80       this.chart.ChartAreas.Add(chartArea1);
    81       legend1.Alignment = System.Drawing.StringAlignment.Center;
    82       legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
    83       legend1.Name = "Default";
    84       this.chart.Legends.Add(legend1);
    8567      this.chart.Location = new System.Drawing.Point(0, 26);
    8668      this.chart.Name = "chart";
    87       series1.ChartArea = "Default";
    88       series1.Legend = "Default";
    89       series1.Name = "Default";
    90       this.chart.Series.Add(series1);
    9169      this.chart.Size = new System.Drawing.Size(359, 248);
    9270      this.chart.TabIndex = 3;
    9371      this.chart.Text = "chart";
    94       title1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    95       title1.Name = "Default";
    96       title1.Text = "Title";
    97       this.chart.Titles.Add(title1);
    98       this.chart.CustomizeLegend += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.CustomizeLegendEventArgs>(this.chart_CustomizeLegend);
    99       this.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);
    100       this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
    10172      //
    10273      // ScatterPlotView
     
    11283      this.Controls.SetChildIndex(this.nameTextBox, 0);
    11384      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    114       ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
    11585      this.ResumeLayout(false);
    11686      this.PerformLayout();
    11787
    11888    }
    119 
    12089    #endregion
    12190
    122     protected HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart chart;
    123 
     91    protected HeuristicLab.Analysis.Views.ScatterPlotControl chart;
    12492  }
    12593}
  • branches/MemPRAlgorithm/HeuristicLab.Analysis.Views/3.3/ScatterPlotView.cs

    r14185 r14562  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Drawing;
    25 using System.Linq;
    2623using System.Windows.Forms;
    27 using System.Windows.Forms.DataVisualization.Charting;
    28 using HeuristicLab.Collections;
    29 using HeuristicLab.Common;
    3024using HeuristicLab.Core.Views;
    3125using HeuristicLab.MainForm;
     
    3529  [Content(typeof(ScatterPlot), true)]
    3630  public partial class ScatterPlotView : NamedItemView, IConfigureableView {
    37     protected List<Series> invisibleSeries;
    38     protected Dictionary<IObservableList<Point2D<double>>, ScatterPlotDataRow> pointsRowsTable;
    39     private double xMin, xMax, yMin, yMax;
    4031
    4132    public new ScatterPlot Content {
     
    4637    public ScatterPlotView() {
    4738      InitializeComponent();
    48       pointsRowsTable = new Dictionary<IObservableList<Point2D<double>>, ScatterPlotDataRow>();
    49       invisibleSeries = new List<Series>();
    50       chart.CustomizeAllChartAreas();
    51       chart.ChartAreas[0].CursorX.Interval = 1;
    5239    }
    53 
    54     #region Event Handler Registration
    55     protected override void DeregisterContentEvents() {
    56       foreach (ScatterPlotDataRow row in Content.Rows)
    57         DeregisterScatterPlotDataRowEvents(row);
    58       Content.VisualPropertiesChanged -= new EventHandler(Content_VisualPropertiesChanged);
    59       Content.Rows.ItemsAdded -= new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsAdded);
    60       Content.Rows.ItemsRemoved -= new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsRemoved);
    61       Content.Rows.ItemsReplaced -= new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsReplaced);
    62       Content.Rows.CollectionReset -= new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_CollectionReset);
    63       base.DeregisterContentEvents();
    64     }
    65     protected override void RegisterContentEvents() {
    66       base.RegisterContentEvents();
    67       Content.VisualPropertiesChanged += new EventHandler(Content_VisualPropertiesChanged);
    68       Content.Rows.ItemsAdded += new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsAdded);
    69       Content.Rows.ItemsRemoved += new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsRemoved);
    70       Content.Rows.ItemsReplaced += new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsReplaced);
    71       Content.Rows.CollectionReset += new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_CollectionReset);
    72     }
    73 
    74     protected virtual void RegisterScatterPlotDataRowEvents(ScatterPlotDataRow row) {
    75       row.NameChanged += new EventHandler(Row_NameChanged);
    76       row.VisualPropertiesChanged += new EventHandler(Row_VisualPropertiesChanged);
    77       pointsRowsTable.Add(row.Points, row);
    78       row.Points.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsAdded);
    79       row.Points.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsRemoved);
    80       row.Points.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsReplaced);
    81       row.Points.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_CollectionReset);
    82     }
    83     protected virtual void DeregisterScatterPlotDataRowEvents(ScatterPlotDataRow row) {
    84       row.Points.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsAdded);
    85       row.Points.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsRemoved);
    86       row.Points.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsReplaced);
    87       row.Points.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_CollectionReset);
    88       pointsRowsTable.Remove(row.Points);
    89       row.VisualPropertiesChanged -= new EventHandler(Row_VisualPropertiesChanged);
    90       row.NameChanged -= new EventHandler(Row_NameChanged);
    91     }
    92     #endregion
    9340
    9441    protected override void OnContentChanged() {
    9542      base.OnContentChanged();
    96       invisibleSeries.Clear();
    97       chart.Titles[0].Text = string.Empty;
    98       chart.ChartAreas[0].AxisX.Title = string.Empty;
    99       chart.ChartAreas[0].AxisY.Title = string.Empty;
    100       chart.Series.Clear();
    101       if (Content != null) {
    102         chart.Titles[0].Text = Content.Name;
    103         AddScatterPlotDataRows(Content.Rows);
    104         ConfigureChartArea(chart.ChartAreas[0]);
    105         RecalculateMinMaxPointValues();
    106         RecalculateAxesScale(chart.ChartAreas[0]);
    107       }
     43      chart.Content = Content;
    10844    }
    10945
     
    11450
    11551    public void ShowConfiguration() {
    116       if (Content != null) {
    117         using (ScatterPlotVisualPropertiesDialog dialog = new ScatterPlotVisualPropertiesDialog(Content)) {
    118           dialog.ShowDialog(this);
    119         }
    120       } else MessageBox.Show("Nothing to configure.");
     52      chart.ShowConfiguration();
    12153    }
    12254
    123     protected virtual void AddScatterPlotDataRows(IEnumerable<ScatterPlotDataRow> rows) {
    124       foreach (var row in rows) {
    125         RegisterScatterPlotDataRowEvents(row);
    126         Series series = new Series(row.Name);
    127         if (row.VisualProperties.DisplayName.Trim() != String.Empty) series.LegendText = row.VisualProperties.DisplayName;
    128         else series.LegendText = row.Name;
    129         ConfigureSeries(series, row);
    130         FillSeriesWithRowValues(series, row);
    131         chart.Series.Add(series);
    132       }
    133       ConfigureChartArea(chart.ChartAreas[0]);
    134       RecalculateMinMaxPointValues();
    135       RecalculateAxesScale(chart.ChartAreas[0]);
    136       UpdateYCursorInterval();
    137     }
    138 
    139     protected virtual void RemoveScatterPlotDataRows(IEnumerable<ScatterPlotDataRow> rows) {
    140       foreach (var row in rows) {
    141         DeregisterScatterPlotDataRowEvents(row);
    142         Series series = chart.Series[row.Name];
    143         chart.Series.Remove(series);
    144         if (invisibleSeries.Contains(series))
    145           invisibleSeries.Remove(series);
    146       }
    147       RecalculateMinMaxPointValues();
    148       RecalculateAxesScale(chart.ChartAreas[0]);
    149     }
    150 
    151     private void ConfigureSeries(Series series, ScatterPlotDataRow row) {
    152       series.BorderWidth = 1;
    153       series.BorderDashStyle = ChartDashStyle.Solid;
    154       series.BorderColor = Color.Empty;
    155 
    156       if (row.VisualProperties.Color != Color.Empty)
    157         series.Color = row.VisualProperties.Color;
    158       else series.Color = Color.Empty;
    159       series.IsVisibleInLegend = row.VisualProperties.IsVisibleInLegend;
    160       series.ChartType = SeriesChartType.FastPoint;
    161       series.MarkerSize = row.VisualProperties.PointSize;
    162       series.MarkerStyle = ConvertPointStyle(row.VisualProperties.PointStyle);
    163       series.XAxisType = AxisType.Primary;
    164       series.YAxisType = AxisType.Primary;
    165 
    166       if (row.VisualProperties.DisplayName.Trim() != String.Empty) series.LegendText = row.VisualProperties.DisplayName;
    167       else series.LegendText = row.Name;
    168 
    169       string xAxisTitle = string.IsNullOrEmpty(Content.VisualProperties.XAxisTitle)
    170                       ? "X"
    171                       : Content.VisualProperties.XAxisTitle;
    172       string yAxisTitle = string.IsNullOrEmpty(Content.VisualProperties.YAxisTitle)
    173                             ? "Y"
    174                             : Content.VisualProperties.YAxisTitle;
    175       series.ToolTip =
    176         series.LegendText + Environment.NewLine +
    177         xAxisTitle + " = " + "#VALX," + Environment.NewLine +
    178         yAxisTitle + " = " + "#VAL";
    179     }
    180 
    181     private void ConfigureChartArea(ChartArea area) {
    182       if (Content.VisualProperties.TitleFont != null) chart.Titles[0].Font = Content.VisualProperties.TitleFont;
    183       if (!Content.VisualProperties.TitleColor.IsEmpty) chart.Titles[0].ForeColor = Content.VisualProperties.TitleColor;
    184       chart.Titles[0].Text = Content.VisualProperties.Title;
    185 
    186       if (Content.VisualProperties.AxisTitleFont != null) area.AxisX.TitleFont = Content.VisualProperties.AxisTitleFont;
    187       if (!Content.VisualProperties.AxisTitleColor.IsEmpty) area.AxisX.TitleForeColor = Content.VisualProperties.AxisTitleColor;
    188       area.AxisX.Title = Content.VisualProperties.XAxisTitle;
    189       area.AxisX.MajorGrid.Enabled = Content.VisualProperties.XAxisGrid;
    190 
    191       if (Content.VisualProperties.AxisTitleFont != null) area.AxisY.TitleFont = Content.VisualProperties.AxisTitleFont;
    192       if (!Content.VisualProperties.AxisTitleColor.IsEmpty) area.AxisY.TitleForeColor = Content.VisualProperties.AxisTitleColor;
    193       area.AxisY.Title = Content.VisualProperties.YAxisTitle;
    194       area.AxisY.MajorGrid.Enabled = Content.VisualProperties.YAxisGrid;
    195     }
    196 
    197     private void RecalculateAxesScale(ChartArea area) {
    198       area.AxisX.Minimum = CalculateMinBound(xMin);
    199       area.AxisX.Maximum = CalculateMaxBound(xMax);
    200       if (area.AxisX.Minimum == area.AxisX.Maximum) {
    201         area.AxisX.Minimum = xMin - 0.5;
    202         area.AxisX.Maximum = xMax + 0.5;
    203       }
    204       area.AxisY.Minimum = CalculateMinBound(yMin);
    205       area.AxisY.Maximum = CalculateMaxBound(yMax);
    206       if (area.AxisY.Minimum == area.AxisY.Maximum) {
    207         area.AxisY.Minimum = yMin - 0.5;
    208         area.AxisY.Maximum = yMax + 0.5;
    209       }
    210       if (xMax - xMin > 0) area.CursorX.Interval = Math.Pow(10, Math.Floor(Math.Log10(area.AxisX.Maximum - area.AxisX.Minimum) - 3));
    211       else area.CursorX.Interval = 1;
    212       area.AxisX.IsMarginVisible = false;
    213 
    214       if (!Content.VisualProperties.XAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.XAxisMinimumFixedValue)) area.AxisX.Minimum = Content.VisualProperties.XAxisMinimumFixedValue;
    215       if (!Content.VisualProperties.XAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.XAxisMaximumFixedValue)) area.AxisX.Maximum = Content.VisualProperties.XAxisMaximumFixedValue;
    216       if (!Content.VisualProperties.YAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.YAxisMinimumFixedValue)) area.AxisY.Minimum = Content.VisualProperties.YAxisMinimumFixedValue;
    217       if (!Content.VisualProperties.YAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.YAxisMaximumFixedValue)) area.AxisY.Maximum = Content.VisualProperties.YAxisMaximumFixedValue;
    218     }
    219 
    220     private static double CalculateMinBound(double min) {
    221       if (min == 0) return 0;
    222       var scale = Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(min))));
    223       return scale * (Math.Floor(min / scale));
    224     }
    225 
    226     private static double CalculateMaxBound(double max) {
    227       if (max == 0) return 0;
    228       var scale = Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(max))));
    229       return scale * (Math.Ceiling(max / scale));
    230     }
    231 
    232     protected virtual void UpdateYCursorInterval() {
    233       double interestingValuesRange = (
    234         from series in chart.Series
    235         where series.Enabled
    236         let values = (from point in series.Points
    237                       where !point.IsEmpty
    238                       select point.YValues[0]).DefaultIfEmpty(1.0)
    239         let range = values.Max() - values.Min()
    240         where range > 0.0
    241         select range
    242         ).DefaultIfEmpty(1.0).Min();
    243 
    244       double digits = (int)Math.Log10(interestingValuesRange) - 3;
    245       double yZoomInterval = Math.Pow(10, digits);
    246       this.chart.ChartAreas[0].CursorY.Interval = yZoomInterval;
    247     }
    248 
    249     #region Event Handlers
    25055    #region Content Event Handlers
    25156    protected override void Content_NameChanged(object sender, EventArgs e) {
     
    25358        Invoke(new EventHandler(Content_NameChanged), sender, e);
    25459      else {
    255         chart.Titles[0].Text = Content.Name;
     60        Content.VisualProperties.Title = Content.Name;
    25661        base.Content_NameChanged(sender, e);
    25762      }
    258     }
    259     private void Content_VisualPropertiesChanged(object sender, EventArgs e) {
    260       if (InvokeRequired)
    261         Invoke(new EventHandler(Content_VisualPropertiesChanged), sender, e);
    262       else {
    263         ConfigureChartArea(chart.ChartAreas[0]);
    264         RecalculateAxesScale(chart.ChartAreas[0]); // axes min/max could have changed
    265       }
    266     }
    267     #endregion
    268     #region Rows Event Handlers
    269     private void Rows_ItemsAdded(object sender, CollectionItemsChangedEventArgs<ScatterPlotDataRow> e) {
    270       if (InvokeRequired)
    271         Invoke(new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsAdded), sender, e);
    272       else {
    273         AddScatterPlotDataRows(e.Items);
    274       }
    275     }
    276     private void Rows_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<ScatterPlotDataRow> e) {
    277       if (InvokeRequired)
    278         Invoke(new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsRemoved), sender, e);
    279       else {
    280         RemoveScatterPlotDataRows(e.Items);
    281       }
    282     }
    283     private void Rows_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<ScatterPlotDataRow> e) {
    284       if (InvokeRequired)
    285         Invoke(new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_ItemsReplaced), sender, e);
    286       else {
    287         RemoveScatterPlotDataRows(e.OldItems);
    288         AddScatterPlotDataRows(e.Items);
    289       }
    290     }
    291     private void Rows_CollectionReset(object sender, CollectionItemsChangedEventArgs<ScatterPlotDataRow> e) {
    292       if (InvokeRequired)
    293         Invoke(new CollectionItemsChangedEventHandler<ScatterPlotDataRow>(Rows_CollectionReset), sender, e);
    294       else {
    295         RemoveScatterPlotDataRows(e.OldItems);
    296         AddScatterPlotDataRows(e.Items);
    297       }
    298     }
    299     #endregion
    300     #region Row Event Handlers
    301     private void Row_VisualPropertiesChanged(object sender, EventArgs e) {
    302       if (InvokeRequired)
    303         Invoke(new EventHandler(Row_VisualPropertiesChanged), sender, e);
    304       else {
    305         ScatterPlotDataRow row = (ScatterPlotDataRow)sender;
    306         Series series = chart.Series[row.Name];
    307         series.Points.Clear();
    308         ConfigureSeries(series, row);
    309         FillSeriesWithRowValues(series, row);
    310         RecalculateMinMaxPointValues();
    311         RecalculateAxesScale(chart.ChartAreas[0]);
    312       }
    313     }
    314     private void Row_NameChanged(object sender, EventArgs e) {
    315       if (InvokeRequired)
    316         Invoke(new EventHandler(Row_NameChanged), sender, e);
    317       else {
    318         ScatterPlotDataRow row = (ScatterPlotDataRow)sender;
    319         chart.Series[row.Name].Name = row.Name;
    320       }
    321     }
    322     #endregion
    323     #region Points Event Handlers
    324     private void Points_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<Point2D<double>>> e) {
    325       if (InvokeRequired)
    326         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsAdded), sender, e);
    327       else {
    328         ScatterPlotDataRow row = null;
    329         pointsRowsTable.TryGetValue((IObservableList<Point2D<double>>)sender, out row);
    330         if (row != null) {
    331           Series rowSeries = chart.Series[row.Name];
    332           if (!invisibleSeries.Contains(rowSeries)) {
    333             rowSeries.Points.Clear();
    334             FillSeriesWithRowValues(rowSeries, row);
    335             RecalculateMinMaxPointValues();
    336             RecalculateAxesScale(chart.ChartAreas[0]);
    337             UpdateYCursorInterval();
    338           }
    339         }
    340       }
    341     }
    342     private void Points_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Point2D<double>>> e) {
    343       if (InvokeRequired)
    344         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsRemoved), sender, e);
    345       else {
    346         ScatterPlotDataRow row = null;
    347         pointsRowsTable.TryGetValue((IObservableList<Point2D<double>>)sender, out row);
    348         if (row != null) {
    349           Series rowSeries = chart.Series[row.Name];
    350           if (!invisibleSeries.Contains(rowSeries)) {
    351             rowSeries.Points.Clear();
    352             FillSeriesWithRowValues(rowSeries, row);
    353             RecalculateMinMaxPointValues();
    354             RecalculateAxesScale(chart.ChartAreas[0]);
    355             UpdateYCursorInterval();
    356           }
    357         }
    358       }
    359     }
    360     private void Points_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<Point2D<double>>> e) {
    361       if (InvokeRequired)
    362         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_ItemsReplaced), sender, e);
    363       else {
    364         ScatterPlotDataRow row = null;
    365         pointsRowsTable.TryGetValue((IObservableList<Point2D<double>>)sender, out row);
    366         if (row != null) {
    367           Series rowSeries = chart.Series[row.Name];
    368           if (!invisibleSeries.Contains(rowSeries)) {
    369             rowSeries.Points.Clear();
    370             FillSeriesWithRowValues(rowSeries, row);
    371             RecalculateMinMaxPointValues();
    372             RecalculateAxesScale(chart.ChartAreas[0]);
    373             UpdateYCursorInterval();
    374           }
    375         }
    376       }
    377     }
    378     private void Points_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<Point2D<double>>> e) {
    379       if (InvokeRequired)
    380         Invoke(new CollectionItemsChangedEventHandler<IndexedItem<Point2D<double>>>(Points_CollectionReset), sender, e);
    381       else {
    382         ScatterPlotDataRow row = null;
    383         pointsRowsTable.TryGetValue((IObservableList<Point2D<double>>)sender, out row);
    384         if (row != null) {
    385           Series rowSeries = chart.Series[row.Name];
    386           if (!invisibleSeries.Contains(rowSeries)) {
    387             rowSeries.Points.Clear();
    388             FillSeriesWithRowValues(rowSeries, row);
    389             RecalculateMinMaxPointValues();
    390             RecalculateAxesScale(chart.ChartAreas[0]);
    391             UpdateYCursorInterval();
    392           }
    393         }
    394       }
    395     }
    396     #endregion
    397     #endregion
    398 
    399     #region Chart Event Handlers
    400     private void chart_MouseDown(object sender, MouseEventArgs e) {
    401       HitTestResult result = chart.HitTest(e.X, e.Y);
    402       if (result.ChartElementType == ChartElementType.LegendItem) {
    403         ToggleSeriesVisible(result.Series);
    404       }
    405     }
    406     private void chart_MouseMove(object sender, MouseEventArgs e) {
    407       HitTestResult result = chart.HitTest(e.X, e.Y);
    408       if (result.ChartElementType == ChartElementType.LegendItem)
    409         this.Cursor = Cursors.Hand;
    410       else
    411         this.Cursor = Cursors.Default;
    412     }
    413     private void chart_CustomizeLegend(object sender, CustomizeLegendEventArgs e) {
    414       foreach (LegendItem legendItem in e.LegendItems) {
    415         var series = chart.Series[legendItem.SeriesName];
    416         if (series != null) {
    417           bool seriesIsInvisible = invisibleSeries.Contains(series);
    418           foreach (LegendCell cell in legendItem.Cells) {
    419             cell.ForeColor = seriesIsInvisible ? Color.Gray : Color.Black;
    420           }
    421         }
    422       }
    423     }
    424     #endregion
    425 
    426     private void ToggleSeriesVisible(Series series) {
    427       if (!invisibleSeries.Contains(series)) {
    428         series.Points.Clear();
    429         invisibleSeries.Add(series);
    430         RecalculateMinMaxPointValues();
    431       } else {
    432         invisibleSeries.Remove(series);
    433         if (Content != null) {
    434 
    435           var row = (from r in Content.Rows
    436                      where r.Name == series.Name
    437                      select r).Single();
    438           FillSeriesWithRowValues(series, row);
    439           RecalculateMinMaxPointValues();
    440           this.chart.Legends[series.Legend].ForeColor = Color.Black;
    441           RecalculateAxesScale(chart.ChartAreas[0]);
    442           UpdateYCursorInterval();
    443         }
    444       }
    445     }
    446 
    447     private void RecalculateMinMaxPointValues() {
    448       yMin = xMin = double.MaxValue;
    449       yMax = xMax = double.MinValue;
    450       foreach (var s in chart.Series.Where(x => x.Enabled)) {
    451         foreach (var p in s.Points) {
    452           double x = p.XValue, y = p.YValues[0];
    453           if (xMin > x) xMin = x;
    454           if (xMax < x) xMax = x;
    455           if (yMin > y) yMin = y;
    456           if (yMax < y) yMax = y;
    457         }
    458       }
    459     }
    460 
    461     private void FillSeriesWithRowValues(Series series, ScatterPlotDataRow row) {
    462       for (int i = 0; i < row.Points.Count; i++) {
    463         var value = row.Points[i];
    464         DataPoint point = new DataPoint();
    465         if (IsInvalidValue(value.X) || IsInvalidValue(value.Y))
    466           point.IsEmpty = true;
    467         else {
    468           point.XValue = value.X;
    469           point.YValues = new double[] { value.Y };
    470         }
    471         series.Points.Add(point);
    472       }
    473     }
    474 
    475     #region Helpers
    476     private MarkerStyle ConvertPointStyle(ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle pointStyle) {
    477       switch (pointStyle) {
    478         case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Circle:
    479           return MarkerStyle.Circle;
    480         case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Cross:
    481           return MarkerStyle.Cross;
    482         case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Diamond:
    483           return MarkerStyle.Diamond;
    484         case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Square:
    485           return MarkerStyle.Square;
    486         case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Star4:
    487           return MarkerStyle.Star4;
    488         case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Star5:
    489           return MarkerStyle.Star5;
    490         case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Star6:
    491           return MarkerStyle.Star6;
    492         case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Star10:
    493           return MarkerStyle.Star10;
    494         case ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Triangle:
    495           return MarkerStyle.Triangle;
    496         default:
    497           return MarkerStyle.None;
    498       }
    499     }
    500 
    501     protected static bool IsInvalidValue(double x) {
    502       return double.IsNaN(x) || x < (double)decimal.MinValue || x > (double)decimal.MaxValue;
    50363    }
    50464    #endregion
Note: See TracChangeset for help on using the changeset viewer.