Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5970 for branches/histogram


Ignore:
Timestamp:
04/06/11 18:37:47 (13 years ago)
Author:
abeham
Message:

#1465

  • Separated HistogramView into a view and a control
  • Added the HistogramControl to ChartControlsExtensions (not yet userfriendly)
Location:
branches/histogram
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/HistogramView.Designer.cs

    r5961 r5970  
    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.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
    49       this.enhancedChart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart();
    50       this.label1 = new System.Windows.Forms.Label();
    51       this.numericUpDown = new System.Windows.Forms.NumericUpDown();
     47      this.histogramControl = new HeuristicLab.Visualization.ChartControlsExtensions.HistogramControl();
    5248      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    53       ((System.ComponentModel.ISupportInitialize)(this.enhancedChart)).BeginInit();
    54       ((System.ComponentModel.ISupportInitialize)(this.numericUpDown)).BeginInit();
    5549      this.SuspendLayout();
    5650      //
     
    6660      this.infoLabel.Location = new System.Drawing.Point(524, 3);
    6761      //
    68       // enhancedChart
     62      // histogramControl
    6963      //
    70       this.enhancedChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     64      this.histogramControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    7165                  | System.Windows.Forms.AnchorStyles.Left)
    7266                  | System.Windows.Forms.AnchorStyles.Right)));
    73       chartArea1.Name = "ChartArea1";
    74       this.enhancedChart.ChartAreas.Add(chartArea1);
    75       this.enhancedChart.Location = new System.Drawing.Point(0, 52);
    76       this.enhancedChart.Name = "enhancedChart";
    77       series1.ChartArea = "ChartArea1";
    78       series1.Name = "Series1";
    79       this.enhancedChart.Series.Add(series1);
    80       this.enhancedChart.Size = new System.Drawing.Size(543, 320);
    81       this.enhancedChart.TabIndex = 3;
    82       //
    83       // label1
    84       //
    85       this.label1.AutoSize = true;
    86       this.label1.Location = new System.Drawing.Point(3, 28);
    87       this.label1.Name = "label1";
    88       this.label1.Size = new System.Drawing.Size(82, 13);
    89       this.label1.TabIndex = 4;
    90       this.label1.Text = "Number of Bins:";
    91       //
    92       // numericUpDown
    93       //
    94       this.numericUpDown.Location = new System.Drawing.Point(91, 26);
    95       this.numericUpDown.Minimum = new decimal(new int[] {
    96             1,
    97             0,
    98             0,
    99             0});
    100       this.numericUpDown.Name = "numericUpDown";
    101       this.numericUpDown.Size = new System.Drawing.Size(61, 20);
    102       this.numericUpDown.TabIndex = 5;
    103       this.numericUpDown.Value = new decimal(new int[] {
    104             10,
    105             0,
    106             0,
    107             0});
    108       this.numericUpDown.ValueChanged += new System.EventHandler(this.numericUpDown_ValueChanged);
     67      this.histogramControl.Location = new System.Drawing.Point(0, 26);
     68      this.histogramControl.Name = "histogramControl";
     69      this.histogramControl.Size = new System.Drawing.Size(543, 346);
     70      this.histogramControl.TabIndex = 3;
    10971      //
    11072      // HistogramView
     
    11274      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    11375      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    114       this.Controls.Add(this.enhancedChart);
    115       this.Controls.Add(this.numericUpDown);
    116       this.Controls.Add(this.label1);
     76      this.Controls.Add(this.histogramControl);
    11777      this.Name = "HistogramView";
    11878      this.Size = new System.Drawing.Size(543, 372);
    119       this.Controls.SetChildIndex(this.label1, 0);
    120       this.Controls.SetChildIndex(this.numericUpDown, 0);
    121       this.Controls.SetChildIndex(this.enhancedChart, 0);
     79      this.Controls.SetChildIndex(this.histogramControl, 0);
    12280      this.Controls.SetChildIndex(this.nameLabel, 0);
    12381      this.Controls.SetChildIndex(this.nameTextBox, 0);
    12482      this.Controls.SetChildIndex(this.infoLabel, 0);
    12583      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    126       ((System.ComponentModel.ISupportInitialize)(this.enhancedChart)).EndInit();
    127       ((System.ComponentModel.ISupportInitialize)(this.numericUpDown)).EndInit();
    12884      this.ResumeLayout(false);
    12985      this.PerformLayout();
     
    13389    #endregion
    13490
    135     private Visualization.ChartControlsExtensions.EnhancedChart enhancedChart;
    136     private System.Windows.Forms.Label label1;
    137     private System.Windows.Forms.NumericUpDown numericUpDown;
     91    private Visualization.ChartControlsExtensions.HistogramControl histogramControl;
     92
    13893  }
    13994}
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/HistogramView.cs

    r5961 r5970  
    2020#endregion
    2121
    22 using System.Drawing;
    23 using System.Linq;
    2422using System.Windows.Forms;
    25 using System.Windows.Forms.DataVisualization.Charting;
    2623using HeuristicLab.Collections;
    2724using HeuristicLab.Core.Views;
     
    5956    #region Event Handlers (Content)
    6057    private void Content_Values_ItemsAdded(object sender, CollectionItemsChangedEventArgs<double> e) {
    61       UpdateChartSettings();
     58      histogramControl.AddPoints(e.Items);
    6259    }
    6360    private void Content_Values_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<double> e) {
    64       InitializeChart();
     61      histogramControl.ClearPoints();
     62      histogramControl.AddPoints(Content.Values);
    6563    }
    6664    private void Content_Values_CollectionReset(object sender, CollectionItemsChangedEventArgs<double> e) {
    67       InitializeChart();
     65      histogramControl.ClearPoints();
     66      histogramControl.AddPoints(Content.Values);
    6867    }
    6968    #endregion
     
    7271      base.OnContentChanged();
    7372      if (Content == null) {
    74         enhancedChart.Series.Clear();
     73        histogramControl.ClearPoints();
    7574      } else {
    76         InitializeChart();
     75        histogramControl.AddPoints(Content.Values);
    7776      }
    7877    }
    7978
    80     private void InitializeChart() {
    81       enhancedChart.Series.Clear();
    82       UpdateChartSettings();
    83     }
    84 
    85     private void UpdateChartSettings() {
    86       if (Content == null || Content.Values.Count < 1) return;
    87 
    88       int bins = (int)numericUpDown.Value;
    89       string histogramSeriesName = "Histogram";
    90 
    91       Series histogramSeries = null;
    92       if (enhancedChart.Series.IndexOf(histogramSeriesName) < 0) {
    93         histogramSeries = enhancedChart.Series.Add(histogramSeriesName);
    94 
    95         histogramSeries.ChartType = SeriesChartType.Column;
    96         histogramSeries.BorderColor = Color.Black;
    97         histogramSeries.BorderWidth = 1;
    98         histogramSeries.BorderDashStyle = ChartDashStyle.Solid;
    99       } else {
    100         histogramSeries = enhancedChart.Series[histogramSeriesName];
    101         histogramSeries.Points.Clear();
    102       }
    103 
    104       double minValue = Content.Values.Min();
    105       double maxValue = Content.Values.Max();
    106       double intervalWidth = (maxValue - minValue) / bins;
    107 
    108       double current = minValue;
    109       int count = 0;
    110       foreach (double v in Content.Values.OrderBy(x => x)) {
    111         if (v < current + intervalWidth) {
    112           count++;
    113         } else {
    114           histogramSeries.Points.AddXY(current + intervalWidth / 2.0, count);
    115           count = 0;
    116           current += intervalWidth;
    117         }
    118       }
    119 
    120       histogramSeries["PointWidth"] = "1";
    121 
    122       ChartArea chartArea = enhancedChart.ChartAreas[histogramSeries.ChartArea];
    123       chartArea.AxisY.Title = "Frequency";
    124       chartArea.AxisX.Minimum = minValue;
    125       chartArea.AxisX.Maximum = maxValue;
    126 
    127       double axisInterval = intervalWidth;
    128       while ((maxValue - minValue) / axisInterval > 10.0) {
    129         axisInterval *= 2.0;
    130       }
    131       chartArea.AxisX.Interval = axisInterval;
    132     }
    133 
    134 
    13579    protected override void SetEnabledStateOfControls() {
    13680      base.SetEnabledStateOfControls();
    137       enhancedChart.Enabled = Content != null;
     81      histogramControl.Enabled = Content != null;
    13882    }
    13983
    14084    #region Event Handlers (child controls)
    141     private void numericUpDown_ValueChanged(object sender, System.EventArgs e) {
    142       UpdateChartSettings();
    143     }
    14485    #endregion
    14586  }
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/HistogramView.resx

    r5961 r5970  
    121121    <value>107, 17</value>
    122122  </metadata>
    123   <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    124     <value>107, 17</value>
    125   </metadata>
    126123  <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    127124    <value>17, 17</value>
  • branches/histogram/HeuristicLab.Visualization.ChartControlsExtensions/3.3/HeuristicLab.Visualization.ChartControlsExtensions-3.3.csproj

    r5163 r5970  
    122122    </Compile>
    123123    <Compile Include="HeuristicLabVisualizationChartControlsExtensionsPlugin.cs" />
     124    <Compile Include="HistogramControl.cs">
     125      <SubType>UserControl</SubType>
     126    </Compile>
     127    <Compile Include="HistogramControl.Designer.cs">
     128      <DependentUpon>HistogramControl.cs</DependentUpon>
     129    </Compile>
    124130    <Compile Include="Properties\AssemblyInfo.cs" />
    125131  </ItemGroup>
Note: See TracChangeset for help on using the changeset viewer.