Changeset 561 for trunk/sources/HeuristicLab.CEDMA.Charting
- Timestamp:
- 09/13/08 13:36:57 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.CEDMA.Charting
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Charting/HeuristicLab.CEDMA.Charting.csproj
r560 r561 50 50 </ItemGroup> 51 51 <ItemGroup> 52 <Compile Include="BubbleChart.cs" /> 53 <Compile Include="BubbleChartControl.cs"> 54 <SubType>UserControl</SubType> 55 </Compile> 56 <Compile Include="BubbleChartControl.Designer.cs"> 57 <DependentUpon>BubbleChartControl.cs</DependentUpon> 58 </Compile> 52 59 <Compile Include="HeuristicLabCedmaChartingPlugin.cs" /> 53 60 <Compile Include="Histogram.cs" /> … … 65 72 <Project>{4F9BB789-D561-436B-B226-2BF44B7D0804}</Project> 66 73 <Name>HeuristicLab.CEDMA.DB.Interfaces</Name> 67 </ProjectReference>68 <ProjectReference Include="..\HeuristicLab.Charting.Data\HeuristicLab.Charting.Data.csproj">69 <Project>{E0740131-AA3E-4A3F-BA03-C9FF8327F4EE}</Project>70 <Name>HeuristicLab.Charting.Data</Name>71 74 </ProjectReference> 72 75 <ProjectReference Include="..\HeuristicLab.Charting\HeuristicLab.Charting.csproj"> … … 88 91 </ItemGroup> 89 92 <ItemGroup> 93 <EmbeddedResource Include="BubbleChartControl.resx"> 94 <DependentUpon>BubbleChartControl.cs</DependentUpon> 95 <SubType>Designer</SubType> 96 </EmbeddedResource> 90 97 <EmbeddedResource Include="ResultListView.resx"> 91 98 <DependentUpon>ResultListView.cs</DependentUpon> -
trunk/sources/HeuristicLab.CEDMA.Charting/HeuristicLabCedmaChartingPlugin.cs
r560 r561 29 29 [PluginFile(Filename = "HeuristicLab.CEDMA.Charting.dll", Filetype = PluginFileType.Assembly)] 30 30 [Dependency(Dependency = "HeuristicLab.Charting")] 31 [Dependency(Dependency = "HeuristicLab.Charting.Data")]32 31 [Dependency(Dependency = "HeuristicLab.Core")] 33 32 [Dependency(Dependency = "HeuristicLab.CEDMA.DB.Interfaces")] -
trunk/sources/HeuristicLab.CEDMA.Charting/ResultList.cs
r560 r561 61 61 set { 62 62 store = value; 63 ReloadList();64 FireChanged();63 Action reloadList = ReloadList; 64 reloadList.BeginInvoke(null, null); 65 65 } 66 66 } 67 67 68 private List<string> variableNames = new List<string>() { TARGET_VARIABLE, TREE_SIZE, TREE_HEIGHT, 68 69 MAPE_TRAINING, MAPE_VALIDATION, MAPE_TEST, … … 76 77 77 78 private void ReloadList() { 78 allVariables.Clear();79 79 List<double> trainingMAPE = new List<double>(); 80 80 List<double> validationMAPE = new List<double>(); … … 86 86 List<double> height = new List<double>(); 87 87 List<double> targetVariable = new List<double>(); 88 allVariables[MAPE_TRAINING] = trainingMAPE; 89 allVariables[MAPE_VALIDATION] = validationMAPE; 90 allVariables[MAPE_TEST] = testMAPE; 91 allVariables[R2_TRAINING] = trainingR2; 92 allVariables[R2_VALIDATION] = validationR2; 93 allVariables[R2_TEST] = testR2; 94 allVariables[TREE_SIZE] = size; 95 allVariables[TREE_HEIGHT] = height; 96 allVariables[TARGET_VARIABLE] = targetVariable; 88 89 lock(allVariables) { 90 allVariables.Clear(); 91 allVariables[MAPE_TRAINING] = trainingMAPE; 92 allVariables[MAPE_VALIDATION] = validationMAPE; 93 allVariables[MAPE_TEST] = testMAPE; 94 allVariables[R2_TRAINING] = trainingR2; 95 allVariables[R2_VALIDATION] = validationR2; 96 allVariables[R2_TEST] = testR2; 97 allVariables[TREE_SIZE] = size; 98 allVariables[TREE_HEIGHT] = height; 99 allVariables[TARGET_VARIABLE] = targetVariable; 100 } 97 101 98 102 var results = store.Select(new Statement(anyEntity, new Entity(cedmaNS + "instanceOf"), new Literal("class:GpFunctionTree"))) … … 106 110 Random random = new Random(); // for adding random noise to int values 107 111 foreach(Statement[] ss in results) { 108 targetVariable.Add(double.NaN); 109 size.Add(double.NaN); 110 height.Add(double.NaN); 111 trainingMAPE.Add(double.NaN); 112 validationMAPE.Add(double.NaN); 113 testMAPE.Add(double.NaN); 114 trainingR2.Add(double.NaN); 115 validationR2.Add(double.NaN); 116 testR2.Add(double.NaN); 117 foreach(Statement s in ss) { 118 if(s.Predicate.Equals(targetVariablePredicate)) { 119 ReplaceLastItem(targetVariable, (double)(int)((Literal)s.Property).Value); 120 } else if(s.Predicate.Equals(treeSizePredicate)) { 121 ReplaceLastItem(size, (double)(int)((Literal)s.Property).Value); 122 } else if(s.Predicate.Equals(treeHeightPredicate)) { 123 ReplaceLastItem(height, (double)(int)((Literal)s.Property).Value); 124 } else if(s.Predicate.Equals(trainingMAPEPredicate)) { 125 ReplaceLastItem(trainingMAPE, (double)((Literal)s.Property).Value); 126 } else if(s.Predicate.Equals(validationMAPEPredicate)) { 127 ReplaceLastItem(validationMAPE, (double)((Literal)s.Property).Value); 128 } else if(s.Predicate.Equals(testMAPEPredicate)) { 129 ReplaceLastItem(testMAPE, (double)((Literal)s.Property).Value); 130 } else if(s.Predicate.Equals(trainingR2Predicate)) { 131 ReplaceLastItem(trainingR2, (double)((Literal)s.Property).Value); 132 } else if(s.Predicate.Equals(validationR2Predicate)) { 133 ReplaceLastItem(validationR2, (double)((Literal)s.Property).Value); 134 } else if(s.Predicate.Equals(testR2Predicate)) { 135 ReplaceLastItem(testR2, (double)((Literal)s.Property).Value); 112 lock(allVariables) { 113 targetVariable.Add(double.NaN); 114 size.Add(double.NaN); 115 height.Add(double.NaN); 116 trainingMAPE.Add(double.NaN); 117 validationMAPE.Add(double.NaN); 118 testMAPE.Add(double.NaN); 119 trainingR2.Add(double.NaN); 120 validationR2.Add(double.NaN); 121 testR2.Add(double.NaN); 122 foreach(Statement s in ss) { 123 if(s.Predicate.Equals(targetVariablePredicate)) { 124 ReplaceLastItem(targetVariable, (double)(int)((Literal)s.Property).Value); 125 } else if(s.Predicate.Equals(treeSizePredicate)) { 126 ReplaceLastItem(size, (double)(int)((Literal)s.Property).Value); 127 } else if(s.Predicate.Equals(treeHeightPredicate)) { 128 ReplaceLastItem(height, (double)(int)((Literal)s.Property).Value); 129 } else if(s.Predicate.Equals(trainingMAPEPredicate)) { 130 ReplaceLastItem(trainingMAPE, (double)((Literal)s.Property).Value); 131 } else if(s.Predicate.Equals(validationMAPEPredicate)) { 132 ReplaceLastItem(validationMAPE, (double)((Literal)s.Property).Value); 133 } else if(s.Predicate.Equals(testMAPEPredicate)) { 134 ReplaceLastItem(testMAPE, (double)((Literal)s.Property).Value); 135 } else if(s.Predicate.Equals(trainingR2Predicate)) { 136 ReplaceLastItem(trainingR2, (double)((Literal)s.Property).Value); 137 } else if(s.Predicate.Equals(validationR2Predicate)) { 138 ReplaceLastItem(validationR2, (double)((Literal)s.Property).Value); 139 } else if(s.Predicate.Equals(testR2Predicate)) { 140 ReplaceLastItem(testR2, (double)((Literal)s.Property).Value); 141 } 136 142 } 137 143 } 144 FireChanged(); 138 145 } 139 146 } … … 154 161 internal Histogram GetHistogram(string variableName) { 155 162 Histogram h = new Histogram(50); 156 h.AddValues(allVariables[variableName]); 163 lock(allVariables) { 164 h.AddValues(allVariables[variableName]); 165 } 157 166 return h; 158 167 } 159 168 160 169 internal IList<double> GetValues(string variableName) { 161 return allVariables[variableName]; 170 List<double> result = new List<double>(); 171 lock(allVariables) { 172 result.AddRange(allVariables[variableName]); 173 } 174 return result; 162 175 } 163 176 } -
trunk/sources/HeuristicLab.CEDMA.Charting/ResultListView.Designer.cs
r560 r561 24 24 /// </summary> 25 25 private void InitializeComponent() { 26 this.dataChart = new HeuristicLab.Charting.Data.DataChartControl(); 26 this.yJitterLabel = new System.Windows.Forms.Label(); 27 this.xJitterlabel = new System.Windows.Forms.Label(); 28 this.xTrackBar = new System.Windows.Forms.TrackBar(); 27 29 this.xAxisLabel = new System.Windows.Forms.Label(); 28 30 this.xAxisComboBox = new System.Windows.Forms.ComboBox(); … … 30 32 this.yAxisComboBox = new System.Windows.Forms.ComboBox(); 31 33 this.yTrackBar = new System.Windows.Forms.TrackBar(); 32 this.xTrackBar = new System.Windows.Forms.TrackBar(); 33 this.xJitterlabel = new System.Windows.Forms.Label(); 34 this.yJitterLabel = new System.Windows.Forms.Label(); 34 this.dataChart = new HeuristicLab.CEDMA.Charting.BubbleChartControl(); 35 this.sizeComboBox = new System.Windows.Forms.ComboBox(); 36 this.sizeLabel = new System.Windows.Forms.Label(); 37 this.invertCheckbox = new System.Windows.Forms.CheckBox(); 38 ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).BeginInit(); 35 39 ((System.ComponentModel.ISupportInitialize)(this.yTrackBar)).BeginInit(); 36 ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).BeginInit();37 40 this.SuspendLayout(); 38 41 // 39 // dataChart 40 // 41 this.dataChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 42 | System.Windows.Forms.AnchorStyles.Left) 43 | System.Windows.Forms.AnchorStyles.Right))); 44 this.dataChart.BackColor = System.Drawing.SystemColors.Control; 45 this.dataChart.Chart = null; 46 this.dataChart.Location = new System.Drawing.Point(3, 30); 47 this.dataChart.Name = "dataChart"; 48 this.dataChart.ScaleOnResize = true; 49 this.dataChart.Size = new System.Drawing.Size(447, 390); 50 this.dataChart.TabIndex = 9; 42 // yJitterLabel 43 // 44 this.yJitterLabel.AutoSize = true; 45 this.yJitterLabel.Location = new System.Drawing.Point(3, 30); 46 this.yJitterLabel.Name = "yJitterLabel"; 47 this.yJitterLabel.Size = new System.Drawing.Size(29, 13); 48 this.yJitterLabel.TabIndex = 13; 49 this.yJitterLabel.Text = "jitter:"; 50 // 51 // xJitterlabel 52 // 53 this.xJitterlabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 54 this.xJitterlabel.AutoSize = true; 55 this.xJitterlabel.Location = new System.Drawing.Point(291, 418); 56 this.xJitterlabel.Name = "xJitterlabel"; 57 this.xJitterlabel.Size = new System.Drawing.Size(29, 13); 58 this.xJitterlabel.TabIndex = 12; 59 this.xJitterlabel.Text = "jitter:"; 60 // 61 // xTrackBar 62 // 63 this.xTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 64 this.xTrackBar.Location = new System.Drawing.Point(326, 418); 65 this.xTrackBar.Maximum = 100; 66 this.xTrackBar.Name = "xTrackBar"; 67 this.xTrackBar.Size = new System.Drawing.Size(121, 45); 68 this.xTrackBar.TabIndex = 11; 69 this.xTrackBar.TickStyle = System.Windows.Forms.TickStyle.None; 70 this.xTrackBar.ValueChanged += new System.EventHandler(this.jitterTrackBar_ValueChanged); 51 71 // 52 72 // xAxisLabel … … 54 74 this.xAxisLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 55 75 this.xAxisLabel.AutoSize = true; 56 this.xAxisLabel.Location = new System.Drawing.Point( 197, 429);76 this.xAxisLabel.Location = new System.Drawing.Point(305, 394); 57 77 this.xAxisLabel.Name = "xAxisLabel"; 58 78 this.xAxisLabel.Size = new System.Drawing.Size(15, 13); … … 64 84 this.xAxisComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 65 85 this.xAxisComboBox.FormattingEnabled = true; 66 this.xAxisComboBox.Location = new System.Drawing.Point( 218, 426);86 this.xAxisComboBox.Location = new System.Drawing.Point(326, 391); 67 87 this.xAxisComboBox.Name = "xAxisComboBox"; 68 88 this.xAxisComboBox.Size = new System.Drawing.Size(121, 21); … … 90 110 // yTrackBar 91 111 // 92 this.yTrackBar.Location = new System.Drawing.Point( 186, 3);112 this.yTrackBar.Location = new System.Drawing.Point(38, 30); 93 113 this.yTrackBar.Maximum = 100; 94 114 this.yTrackBar.Name = "yTrackBar"; 95 this.yTrackBar.Size = new System.Drawing.Size( 60, 45);115 this.yTrackBar.Size = new System.Drawing.Size(107, 45); 96 116 this.yTrackBar.TabIndex = 10; 97 117 this.yTrackBar.TickStyle = System.Windows.Forms.TickStyle.None; 98 this.yTrackBar.ValueChanged += new System.EventHandler(this.yTrackBar_ValueChanged); 99 // 100 // xTrackBar 101 // 102 this.xTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 103 this.xTrackBar.Location = new System.Drawing.Point(387, 426); 104 this.xTrackBar.Maximum = 100; 105 this.xTrackBar.Name = "xTrackBar"; 106 this.xTrackBar.Size = new System.Drawing.Size(60, 45); 107 this.xTrackBar.TabIndex = 11; 108 this.xTrackBar.TickStyle = System.Windows.Forms.TickStyle.None; 109 this.xTrackBar.ValueChanged += new System.EventHandler(this.xTrackBar_ValueChanged); 110 // 111 // xJitterlabel 112 // 113 this.xJitterlabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 114 this.xJitterlabel.AutoSize = true; 115 this.xJitterlabel.Location = new System.Drawing.Point(352, 429); 116 this.xJitterlabel.Name = "xJitterlabel"; 117 this.xJitterlabel.Size = new System.Drawing.Size(29, 13); 118 this.xJitterlabel.TabIndex = 12; 119 this.xJitterlabel.Text = "jitter:"; 120 // 121 // yJitterLabel 122 // 123 this.yJitterLabel.AutoSize = true; 124 this.yJitterLabel.Location = new System.Drawing.Point(151, 6); 125 this.yJitterLabel.Name = "yJitterLabel"; 126 this.yJitterLabel.Size = new System.Drawing.Size(29, 13); 127 this.yJitterLabel.TabIndex = 13; 128 this.yJitterLabel.Text = "jitter:"; 118 this.yTrackBar.ValueChanged += new System.EventHandler(this.jitterTrackBar_ValueChanged); 119 // 120 // dataChart 121 // 122 this.dataChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 123 | System.Windows.Forms.AnchorStyles.Left) 124 | System.Windows.Forms.AnchorStyles.Right))); 125 this.dataChart.BackColor = System.Drawing.SystemColors.Control; 126 this.dataChart.Chart = null; 127 this.dataChart.Location = new System.Drawing.Point(3, 81); 128 this.dataChart.Name = "dataChart"; 129 this.dataChart.ScaleOnResize = true; 130 this.dataChart.Size = new System.Drawing.Size(447, 304); 131 this.dataChart.TabIndex = 9; 132 // 133 // sizeComboBox 134 // 135 this.sizeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 136 this.sizeComboBox.FormattingEnabled = true; 137 this.sizeComboBox.Location = new System.Drawing.Point(329, 3); 138 this.sizeComboBox.Name = "sizeComboBox"; 139 this.sizeComboBox.Size = new System.Drawing.Size(121, 21); 140 this.sizeComboBox.TabIndex = 14; 141 this.sizeComboBox.SelectedIndexChanged += new System.EventHandler(this.sizeComboBox_SelectedIndexChanged); 142 // 143 // sizeLabel 144 // 145 this.sizeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 146 this.sizeLabel.AutoSize = true; 147 this.sizeLabel.Location = new System.Drawing.Point(259, 6); 148 this.sizeLabel.Name = "sizeLabel"; 149 this.sizeLabel.Size = new System.Drawing.Size(64, 13); 150 this.sizeLabel.TabIndex = 15; 151 this.sizeLabel.Text = "Bubble size:"; 152 // 153 // invertCheckbox 154 // 155 this.invertCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 156 this.invertCheckbox.AutoSize = true; 157 this.invertCheckbox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight; 158 this.invertCheckbox.Location = new System.Drawing.Point(326, 30); 159 this.invertCheckbox.Name = "invertCheckbox"; 160 this.invertCheckbox.Size = new System.Drawing.Size(64, 17); 161 this.invertCheckbox.TabIndex = 16; 162 this.invertCheckbox.Text = "Inverse:"; 163 this.invertCheckbox.UseVisualStyleBackColor = true; 164 this.invertCheckbox.CheckedChanged += new System.EventHandler(this.sizeComboBox_SelectedIndexChanged); 129 165 // 130 166 // ResultListView … … 132 168 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 133 169 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 170 this.Controls.Add(this.invertCheckbox); 171 this.Controls.Add(this.sizeLabel); 172 this.Controls.Add(this.sizeComboBox); 173 this.Controls.Add(this.dataChart); 134 174 this.Controls.Add(this.yJitterLabel); 135 175 this.Controls.Add(this.xJitterlabel); 136 176 this.Controls.Add(this.xTrackBar); 137 this.Controls.Add(this.dataChart);138 177 this.Controls.Add(this.xAxisLabel); 139 178 this.Controls.Add(this.xAxisComboBox); … … 142 181 this.Controls.Add(this.yTrackBar); 143 182 this.Name = "ResultListView"; 144 this.Size = new System.Drawing.Size(450, 450); 183 this.Size = new System.Drawing.Size(450, 459); 184 ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).EndInit(); 145 185 ((System.ComponentModel.ISupportInitialize)(this.yTrackBar)).EndInit(); 146 ((System.ComponentModel.ISupportInitialize)(this.xTrackBar)).EndInit();147 186 this.ResumeLayout(false); 148 187 this.PerformLayout(); … … 152 191 #endregion 153 192 154 private HeuristicLab.Charting.Data.DataChartControl dataChart;193 private BubbleChartControl dataChart; 155 194 private System.Windows.Forms.Label xAxisLabel; 156 195 private System.Windows.Forms.ComboBox xAxisComboBox; … … 161 200 private System.Windows.Forms.Label xJitterlabel; 162 201 private System.Windows.Forms.Label yJitterLabel; 202 private System.Windows.Forms.ComboBox sizeComboBox; 203 private System.Windows.Forms.Label sizeLabel; 204 private System.Windows.Forms.CheckBox invertCheckbox; 163 205 } 164 206 } -
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.