Changeset 554 for trunk/sources/HeuristicLab.CEDMA.Core/ResultListView.cs
- Timestamp:
- 09/12/08 11:24:03 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Core/ResultListView.cs
r553 r554 14 14 private ResultList results; 15 15 private const string FREQUENCY = "<Frequency>"; 16 private double xJitterFactor = 0.0; 17 private double yJitterFactor = 0.0; 18 private double maxXJitterPercent = .1; 19 private double maxYJitterPercent = .1; 16 20 17 21 public ResultListView(ResultList results) { … … 25 29 26 30 private void yAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) { 31 yJitterFactor = 0.0; 32 yTrackBar.Value = 0; 27 33 UpdateChart(); 28 34 } 29 35 30 36 private void xAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) { 37 xJitterFactor = 0.0; 38 xTrackBar.Value = 0; 31 39 UpdateChart(); 32 40 } 33 41 34 42 private void UpdateChart() { 43 if(xAxisComboBox.SelectedItem == null || yAxisComboBox.SelectedItem == null) return; 44 if(yAxisComboBox.SelectedItem.Equals(FREQUENCY)) { 45 CreateHistogramChart(); 46 } else { 47 CreateScatterplot(); 48 } 49 } 50 51 private void CreateScatterplot() { 35 52 double minX = double.PositiveInfinity; 36 53 double minY = double.PositiveInfinity; 37 54 double maxX = double.NegativeInfinity; 38 55 double maxY = double.NegativeInfinity; 39 if(xAxisComboBox.SelectedItem == null || yAxisComboBox.SelectedItem == null) return; 40 if(yAxisComboBox.SelectedItem.Equals(FREQUENCY)) { 41 Color curCol = Color.Blue; 42 Pen p = new Pen(curCol); 43 SolidBrush b = new SolidBrush(curCol); 44 // frequency 45 dataChart.Chart = new HeuristicLab.Charting.Data.Datachart(0, 0, 100, 100); 46 dataChart.Chart.UpdateEnabled = false; 47 dataChart.Chart.Group.Add(new Axis(dataChart.Chart, 0, 0, AxisType.Both)); 48 Histogram h = results.GetHistogram((string)xAxisComboBox.SelectedItem); 49 for(int i = 0; i < h.Buckets; i++) { 50 double lower = h.LowerValue(i); 51 double upper = h.UpperValue(i); 52 int freq = h.Frequency(i); 53 if(lower < minX) minX = lower; 54 if(upper > maxX) maxX = upper; 55 if(freq > maxY) maxY = freq; 56 dataChart.Chart.AddDataRow(HeuristicLab.Charting.Data.DataRowType.Bars, p, b); 57 dataChart.Chart.AddDataPoint(0, lower, 0); 58 dataChart.Chart.AddDataPoint(0, upper, freq); 56 57 xTrackBar.Enabled = true; 58 yTrackBar.Enabled = true; 59 Random random = new Random(); 60 Color curCol = Color.FromArgb(30, Color.Blue); 61 Pen p = new Pen(curCol); 62 SolidBrush b = new SolidBrush(curCol); 63 IList<double> xs = results.GetValues((string)xAxisComboBox.SelectedItem); 64 IList<double> ys = results.GetValues((string)yAxisComboBox.SelectedItem); 65 dataChart.Chart = new HeuristicLab.Charting.Data.Datachart(0, 0, 100, 100); 66 dataChart.Chart.UpdateEnabled = false; 67 dataChart.Chart.Group.Add(new Axis(dataChart.Chart, 0, 0, AxisType.Both)); 68 dataChart.Chart.AddDataRow(HeuristicLab.Charting.Data.DataRowType.Points, p, b); 69 for(int i = 0; i < xs.Count; i++) { 70 double x = xs[i] + (random.NextDouble() * 2.0 - 1.0) * xJitterFactor; 71 double y = ys[i] + (random.NextDouble() * 2.0 - 1.0) * yJitterFactor; 72 if(double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN; 73 if(double.IsInfinity(y) || y == double.MaxValue || y == double.MinValue) y = double.NaN; 74 if(!double.IsNaN(x) && !double.IsNaN(y)) { 75 dataChart.Chart.AddDataPoint(0, x, y); 76 if(x > maxX) maxX = x; 77 if(y > maxY) maxY = y; 78 if(x < minX) minX = x; 79 if(y < minY) minY = y; 59 80 } 60 minY = 0; 81 } 82 dataChart.Chart.UpdateEnabled = true; 83 if(minX<maxX && minY<maxY) dataChart.Chart.ZoomIn(minX, minY, maxX, maxY); 84 } 61 85 62 dataChart.Chart.UpdateEnabled = true; 63 } else { 64 Color curCol = Color.FromArgb(30, Color.Blue); 65 Pen p = new Pen(curCol); 66 SolidBrush b = new SolidBrush(curCol); 67 IList<double> xs = results.GetValues((string)xAxisComboBox.SelectedItem); 68 IList<double> ys = results.GetValues((string)yAxisComboBox.SelectedItem); 69 dataChart.Chart = new HeuristicLab.Charting.Data.Datachart(0, 0, 100, 100); 70 dataChart.Chart.UpdateEnabled = false; 71 dataChart.Chart.Group.Add(new Axis(dataChart.Chart, 0, 0, AxisType.Both)); 72 dataChart.Chart.AddDataRow(HeuristicLab.Charting.Data.DataRowType.Points, p, b); 73 for(int i = 0; i < xs.Count; i++) { 74 double x = xs[i]; 75 double y = ys[i]; 76 if(double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN; 77 if(double.IsInfinity(y) || y == double.MaxValue || y == double.MinValue) y = double.NaN; 78 if(!double.IsNaN(x) && !double.IsNaN(y)) { 79 dataChart.Chart.AddDataPoint(0, x, y); 80 if(x > maxX) maxX = x; 81 if(y > maxY) maxY = y; 82 if(x < minX) minX = x; 83 if(y < minY) minY = y; 84 } 85 } 86 dataChart.Chart.UpdateEnabled = true; 86 private void CreateHistogramChart() { 87 double minX = double.PositiveInfinity; 88 double minY = double.PositiveInfinity; 89 double maxX = double.NegativeInfinity; 90 double maxY = double.NegativeInfinity; 91 92 xTrackBar.Enabled = false; 93 yTrackBar.Enabled = false; 94 Color curCol = Color.Blue; 95 Pen p = new Pen(curCol); 96 SolidBrush b = new SolidBrush(curCol); 97 // frequency 98 dataChart.Chart = new HeuristicLab.Charting.Data.Datachart(0, 0, 100, 100); 99 dataChart.Chart.UpdateEnabled = false; 100 dataChart.Chart.Group.Add(new Axis(dataChart.Chart, 0, 0, AxisType.Both)); 101 Histogram h = results.GetHistogram((string)xAxisComboBox.SelectedItem); 102 for(int i = 0; i < h.Buckets; i++) { 103 double lower = h.LowerValue(i); 104 double upper = h.UpperValue(i); 105 int freq = h.Frequency(i); 106 if(lower < minX) minX = lower; 107 if(upper > maxX) maxX = upper; 108 if(freq > maxY) maxY = freq; 109 dataChart.Chart.AddDataRow(HeuristicLab.Charting.Data.DataRowType.Bars, p, b); 110 dataChart.Chart.AddDataPoint(0, lower, 0); 111 dataChart.Chart.AddDataPoint(0, upper, freq); 87 112 } 113 minY = 0; 114 dataChart.Chart.UpdateEnabled = true; 115 if(minX < maxX && minY < maxY) dataChart.Chart.ZoomIn(minX, minY, maxX, maxY); 116 } 88 117 89 dataChart.Chart.ZoomIn(minX, minY, maxX, maxY); 118 private void yTrackBar_ValueChanged(object sender, EventArgs e) { 119 if(dataChart.Chart != null) { 120 yJitterFactor = yTrackBar.Value / 100.0 * maxYJitterPercent * dataChart.Chart.Size.Height; 121 } 122 UpdateChart(); 123 } 124 125 private void xTrackBar_ValueChanged(object sender, EventArgs e) { 126 if(dataChart.Chart != null) { 127 xJitterFactor = xTrackBar.Value / 100.0 * maxXJitterPercent * dataChart.Chart.Size.Width; 128 } 129 UpdateChart(); 90 130 } 91 131 }
Note: See TracChangeset
for help on using the changeset viewer.