- Timestamp:
- 03/24/15 11:17:08 (9 years ago)
- Location:
- branches/HeuristicLab.DatasetRefactor/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DatasetRefactor/sources
- Property svn:mergeinfo changed
-
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Analysis.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Analysis.Views merged: 12134,12139-12140,12143,12145,12173
- Property svn:mergeinfo changed
-
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Analysis.Views/3.3/HistogramControl.Designer.cs
r12031 r12247 55 55 this.label1 = new System.Windows.Forms.Label(); 56 56 this.exactCheckBox = new System.Windows.Forms.CheckBox(); 57 this.label2 = new System.Windows.Forms.Label(); 58 this.bandwidthNumericUpDown = new System.Windows.Forms.NumericUpDown(); 57 59 ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit(); 58 60 ((System.ComponentModel.ISupportInitialize)(this.binsNumericUpDown)).BeginInit(); 61 ((System.ComponentModel.ISupportInitialize)(this.bandwidthNumericUpDown)).BeginInit(); 59 62 this.SuspendLayout(); 60 63 // 61 64 // chart 62 65 // 63 this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 64 | System.Windows.Forms.AnchorStyles.Left) 66 this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 67 | System.Windows.Forms.AnchorStyles.Left) 65 68 | System.Windows.Forms.AnchorStyles.Right))); 66 69 chartArea1.Name = "ChartArea1"; … … 88 91 0}); 89 92 this.binsNumericUpDown.Minimum = new decimal(new int[] { 90 1,93 2, 91 94 0, 92 95 0, … … 115 118 this.exactCheckBox.AutoSize = true; 116 119 this.exactCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight; 117 this.exactCheckBox.Location = new System.Drawing.Point( 158, 4);120 this.exactCheckBox.Location = new System.Drawing.Point(291, 4); 118 121 this.exactCheckBox.Name = "exactCheckBox"; 119 122 this.exactCheckBox.Size = new System.Drawing.Size(56, 17); … … 123 126 this.exactCheckBox.CheckedChanged += new System.EventHandler(this.exactCheckBox_CheckedChanged); 124 127 // 128 // label2 129 // 130 this.label2.AutoSize = true; 131 this.label2.Location = new System.Drawing.Point(158, 5); 132 this.label2.Name = "label2"; 133 this.label2.Size = new System.Drawing.Size(60, 13); 134 this.label2.TabIndex = 5; 135 this.label2.Text = "Bandwidth:"; 136 // 137 // bandwidthNumericUpDown 138 // 139 this.bandwidthNumericUpDown.DecimalPlaces = 2; 140 this.bandwidthNumericUpDown.Location = new System.Drawing.Point(224, 3); 141 this.bandwidthNumericUpDown.Maximum = new decimal(new int[] { 142 100000000, 143 0, 144 0, 145 0}); 146 this.bandwidthNumericUpDown.Minimum = new decimal(new int[] { 147 1, 148 0, 149 0, 150 851968}); 151 this.bandwidthNumericUpDown.Name = "bandwidthNumericUpDown"; 152 this.bandwidthNumericUpDown.Size = new System.Drawing.Size(61, 20); 153 this.bandwidthNumericUpDown.TabIndex = 4; 154 this.bandwidthNumericUpDown.Value = new decimal(new int[] { 155 1, 156 0, 157 0, 158 0}); 159 this.bandwidthNumericUpDown.ValueChanged += new System.EventHandler(this.bandwidthNumericUpDown_ValueChanged); 160 // 125 161 // HistogramControl 126 162 // 127 163 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 164 this.Controls.Add(this.label2); 165 this.Controls.Add(this.bandwidthNumericUpDown); 128 166 this.Controls.Add(this.exactCheckBox); 129 167 this.Controls.Add(this.label1); … … 134 172 ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit(); 135 173 ((System.ComponentModel.ISupportInitialize)(this.binsNumericUpDown)).EndInit(); 174 ((System.ComponentModel.ISupportInitialize)(this.bandwidthNumericUpDown)).EndInit(); 136 175 this.ResumeLayout(false); 137 176 this.PerformLayout(); … … 145 184 private System.Windows.Forms.Label label1; 146 185 private System.Windows.Forms.CheckBox exactCheckBox; 186 private System.Windows.Forms.Label label2; 187 private System.Windows.Forms.NumericUpDown bandwidthNumericUpDown; 147 188 } 148 189 } -
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Analysis.Views/3.3/HistogramControl.cs
r12031 r12247 31 31 public partial class HistogramControl : UserControl { 32 32 protected static readonly string SeriesName = "Histogram"; 33 33 protected static readonly decimal bandwidthMin = 0.0000000000001m; 34 34 protected Dictionary<string, List<double>> points; 35 protected bool suppressUpdate; 36 35 37 public int NumberOfBins { 36 38 get { return (int)binsNumericUpDown.Value; } … … 123 125 } 124 126 125 protected void UpdateHistogram( ) {127 protected void UpdateHistogram(double bandwith = double.NaN) { 126 128 if (InvokeRequired) { 127 Invoke((Action )UpdateHistogram, null);129 Invoke((Action<double>)UpdateHistogram, bandwith); 128 130 return; 129 131 } … … 134 136 135 137 chart.Series.Clear(); 136 137 138 foreach (var point in points) { 138 139 if (!point.Value.Any()) continue; … … 140 141 Series histogramSeries = new Series(point.Key); 141 142 chart.Series.Add(histogramSeries); 142 143 143 double minValue = point.Value.Min(); 144 144 double maxValue = point.Value.Max(); … … 165 165 histogramSeries["PointWidth"] = "1"; 166 166 167 CalculateDensity(histogramSeries, point.Value);168 169 167 overallMax = Math.Max(overallMax, maxValue); 170 168 overallMin = Math.Min(overallMin, minValue); 169 170 chart.ApplyPaletteColors(); 171 CalculateDensity(histogramSeries, point.Value, bandwith); 171 172 } 172 173 173 174 ChartArea chartArea = chart.ChartAreas[0]; 175 // don't show grid lines for second y-axis 176 chartArea.AxisY2.MajorGrid.Enabled = false; 177 chartArea.AxisY2.MinorGrid.Enabled = false; 174 178 chartArea.AxisY.Title = "Frequency"; 175 179 … … 182 186 } 183 187 184 protected void CalculateDensity(Series series, List<double> row ) {188 protected void CalculateDensity(Series series, List<double> row, double bandwidth = double.NaN) { 185 189 string densitySeriesName = "Density " + series.Name; 186 190 double stepWidth = series.Points[1].XValue - series.Points[0].XValue; 191 var rowArray = row.ToArray(); 187 192 188 193 if (chart.Series.Any(x => x.Name == densitySeriesName)) { … … 191 196 } 192 197 193 var density = NormalDistribution.Density(row.ToArray(), row.Count, stepWidth); 198 if (double.IsNaN(bandwidth)) { 199 bandwidth = KernelDensityEstimator.EstimateBandwidth(rowArray); 200 decimal bwDecimal = (decimal)bandwidth; 201 if (bwDecimal < bandwidthMin) { 202 bwDecimal = bandwidthMin; 203 bandwidth = decimal.ToDouble(bwDecimal); 204 } 205 suppressUpdate = true; 206 bandwidthNumericUpDown.Value = bwDecimal; 207 } 208 var density = KernelDensityEstimator.Density(rowArray, rowArray.Length, stepWidth, bandwidth); 194 209 195 210 Series newSeries = new Series(densitySeriesName); 211 newSeries.Color = series.Color; 196 212 newSeries.ChartType = SeriesChartType.FastLine; 197 213 newSeries.BorderWidth = 2; … … 200 216 } 201 217 218 // densities should be plotted on the second axis (different scale) 219 newSeries.YAxisType = AxisType.Secondary; 202 220 chart.Series.Add(newSeries); 203 221 } … … 221 239 UpdateHistogram(); 222 240 } 241 242 private void bandwidthNumericUpDown_ValueChanged(object sender, EventArgs e) { 243 if (!suppressUpdate) { 244 UpdateHistogram(decimal.ToDouble(bandwidthNumericUpDown.Value)); 245 } 246 suppressUpdate = false; 247 } 223 248 } 224 249 }
Note: See TracChangeset
for help on using the changeset viewer.