- Timestamp:
- 09/13/08 13:36:57 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Charting/ResultListView.cs
r560 r561 14 14 private ResultList results; 15 15 private const string FREQUENCY = "<Frequency>"; 16 private const string CONSTANT_SIZE = "<constant>"; 16 17 private double xJitterFactor = 0.0; 17 18 private double yJitterFactor = 0.0; … … 21 22 public ResultListView(ResultList results) { 22 23 this.results = results; 24 results.Changed += new EventHandler(results_Changed); 23 25 InitializeComponent(); 24 dataChart.Chart = new HeuristicLab.Charting.Data.Datachart(0, 0, 100, 1);25 26 xAxisComboBox.Items.AddRange(results.VariableNames); 26 27 yAxisComboBox.Items.Add(FREQUENCY); 27 28 yAxisComboBox.Items.AddRange(results.VariableNames); 29 sizeComboBox.Items.Add(CONSTANT_SIZE); 30 sizeComboBox.Items.AddRange(results.VariableNames); 31 sizeComboBox.SelectedItem = sizeComboBox.Items[0]; 32 InitChart(); 33 } 34 35 private DateTime lastUpdate = DateTime.Now; 36 void results_Changed(object sender, EventArgs e) { 37 if(DateTime.Now.Subtract(lastUpdate).TotalSeconds < 3) return; 38 lastUpdate = DateTime.Now; 39 InitChart(); 40 } 41 42 private void InitChart() { 43 dataChart.Chart = new BubbleChart(0, 0, 100, 100); 44 foreach(string dim in results.VariableNames) { 45 dataChart.Chart.AddDimension(dim); 46 IList<double> xs = results.GetValues(dim); 47 for(int i = 0; i < xs.Count; i++) { 48 double x = xs[i]; 49 if(double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN; 50 if(!double.IsNaN(x)) { 51 dataChart.Chart.AddDataPoint(dim, x); 52 } 53 } 54 } 28 55 } 29 56 … … 45 72 CreateHistogramChart(); 46 73 } else { 47 CreateScatterplot();74 dataChart.Chart.ShowXvsY((string)xAxisComboBox.SelectedItem, (string)yAxisComboBox.SelectedItem); 48 75 } 49 76 } 50 77 51 private void CreateScatterplot() { 52 double minX = double.PositiveInfinity; 53 double minY = double.PositiveInfinity; 54 double maxX = double.NegativeInfinity; 55 double maxY = double.NegativeInfinity; 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; 80 } 81 } 82 dataChart.Chart.UpdateEnabled = true; 83 if(minX<maxX && minY<maxY) dataChart.Chart.ZoomIn(minX, minY, maxX, maxY); 78 private void CreateHistogramChart() { 79 // TASK 84 80 } 85 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); 112 } 113 minY = 0; 114 dataChart.Chart.UpdateEnabled = true; 115 if(minX < maxX && minY < maxY) dataChart.Chart.ZoomIn(minX, minY, maxX, maxY); 116 } 117 118 private void yTrackBar_ValueChanged(object sender, EventArgs e) { 81 82 private void jitterTrackBar_ValueChanged(object sender, EventArgs e) { 119 83 if(dataChart.Chart != null) { 120 yJitterFactor = yTrackBar.Value / 100.0 * maxYJitterPercent * dataChart.Chart.Size.Height; 84 double xJitterFactor = xTrackBar.Value / 100.0 ; 85 double yJitterFactor = yTrackBar.Value / 100.0 ; 86 dataChart.Chart.SetJitter(xJitterFactor, yJitterFactor); 121 87 } 122 88 UpdateChart(); 123 89 } 124 90 125 private void xTrackBar_ValueChanged(object sender, EventArgs e) {91 private void sizeComboBox_SelectedIndexChanged(object sender, EventArgs e) { 126 92 if(dataChart.Chart != null) { 127 xJitterFactor = xTrackBar.Value / 100.0 * maxXJitterPercent * dataChart.Chart.Size.Width; 93 dataChart.Chart.SetBubbleSizeDimension((string)sizeComboBox.SelectedItem, invertCheckbox.Checked); 94 UpdateChart(); 128 95 } 129 UpdateChart();130 96 } 131 97 }
Note: See TracChangeset
for help on using the changeset viewer.