Changeset 5970
- Timestamp:
- 04/06/11 18:37:47 (14 years ago)
- Location:
- branches/histogram
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/histogram/HeuristicLab.Analysis.Views/3.3/HistogramView.Designer.cs
r5961 r5970 45 45 /// </summary> 46 46 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(); 52 48 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 53 ((System.ComponentModel.ISupportInitialize)(this.enhancedChart)).BeginInit();54 ((System.ComponentModel.ISupportInitialize)(this.numericUpDown)).BeginInit();55 49 this.SuspendLayout(); 56 50 // … … 66 60 this.infoLabel.Location = new System.Drawing.Point(524, 3); 67 61 // 68 // enhancedChart62 // histogramControl 69 63 // 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) 71 65 | System.Windows.Forms.AnchorStyles.Left) 72 66 | 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; 109 71 // 110 72 // HistogramView … … 112 74 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 113 75 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); 117 77 this.Name = "HistogramView"; 118 78 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); 122 80 this.Controls.SetChildIndex(this.nameLabel, 0); 123 81 this.Controls.SetChildIndex(this.nameTextBox, 0); 124 82 this.Controls.SetChildIndex(this.infoLabel, 0); 125 83 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 126 ((System.ComponentModel.ISupportInitialize)(this.enhancedChart)).EndInit();127 ((System.ComponentModel.ISupportInitialize)(this.numericUpDown)).EndInit();128 84 this.ResumeLayout(false); 129 85 this.PerformLayout(); … … 133 89 #endregion 134 90 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 138 93 } 139 94 } -
branches/histogram/HeuristicLab.Analysis.Views/3.3/HistogramView.cs
r5961 r5970 20 20 #endregion 21 21 22 using System.Drawing;23 using System.Linq;24 22 using System.Windows.Forms; 25 using System.Windows.Forms.DataVisualization.Charting;26 23 using HeuristicLab.Collections; 27 24 using HeuristicLab.Core.Views; … … 59 56 #region Event Handlers (Content) 60 57 private void Content_Values_ItemsAdded(object sender, CollectionItemsChangedEventArgs<double> e) { 61 UpdateChartSettings();58 histogramControl.AddPoints(e.Items); 62 59 } 63 60 private void Content_Values_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<double> e) { 64 InitializeChart(); 61 histogramControl.ClearPoints(); 62 histogramControl.AddPoints(Content.Values); 65 63 } 66 64 private void Content_Values_CollectionReset(object sender, CollectionItemsChangedEventArgs<double> e) { 67 InitializeChart(); 65 histogramControl.ClearPoints(); 66 histogramControl.AddPoints(Content.Values); 68 67 } 69 68 #endregion … … 72 71 base.OnContentChanged(); 73 72 if (Content == null) { 74 enhancedChart.Series.Clear();73 histogramControl.ClearPoints(); 75 74 } else { 76 InitializeChart();75 histogramControl.AddPoints(Content.Values); 77 76 } 78 77 } 79 78 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 135 79 protected override void SetEnabledStateOfControls() { 136 80 base.SetEnabledStateOfControls(); 137 enhancedChart.Enabled = Content != null;81 histogramControl.Enabled = Content != null; 138 82 } 139 83 140 84 #region Event Handlers (child controls) 141 private void numericUpDown_ValueChanged(object sender, System.EventArgs e) {142 UpdateChartSettings();143 }144 85 #endregion 145 86 } -
branches/histogram/HeuristicLab.Analysis.Views/3.3/HistogramView.resx
r5961 r5970 121 121 <value>107, 17</value> 122 122 </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>126 123 <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 127 124 <value>17, 17</value> -
branches/histogram/HeuristicLab.Visualization.ChartControlsExtensions/3.3/HeuristicLab.Visualization.ChartControlsExtensions-3.3.csproj
r5163 r5970 122 122 </Compile> 123 123 <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> 124 130 <Compile Include="Properties\AssemblyInfo.cs" /> 125 131 </ItemGroup>
Note: See TracChangeset
for help on using the changeset viewer.