Changeset 7406 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.cs
- Timestamp:
- 01/24/12 16:50:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.cs
r7335 r7406 26 26 using System.Windows.Forms.DataVisualization.Charting; 27 27 using HeuristicLab.MainForm; 28 using HeuristicLab.MainForm.WindowsForms;29 28 30 29 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 66 65 this.chart.Series[TARGETVARIABLE_SERIES_NAME].LegendText = Content.ProblemData.TargetVariable; 67 66 this.chart.Series[TARGETVARIABLE_SERIES_NAME].ChartType = SeriesChartType.FastLine; 68 this.chart.Series[TARGETVARIABLE_SERIES_NAME].EmptyPointStyle.Color = this.chart.Series[TARGETVARIABLE_SERIES_NAME].Color;69 67 this.chart.Series[TARGETVARIABLE_SERIES_NAME].Points.DataBindXY(Enumerable.Range(0, Content.ProblemData.Dataset.Rows).ToArray(), 70 68 Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray()); … … 75 73 this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.Color = this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Color; 76 74 this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TrainingIndizes.ToArray(), Content.EstimatedTrainingValues.ToArray()); 75 this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME]); 77 76 this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Tag = Content; 78 77 // test series … … 80 79 this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].LegendText = ESTIMATEDVALUES_TEST_SERIES_NAME; 81 80 this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].ChartType = SeriesChartType.FastLine; 82 this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].EmptyPointStyle.Color = this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Color;83 81 this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TestIndizes.ToArray(), Content.EstimatedTestValues.ToArray()); 82 this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME]); 84 83 this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Tag = Content; 85 84 // series of remaining points … … 87 86 var estimatedValues = Content.EstimatedValues.ToArray(); 88 87 List<double> allEstimatedValues = allIndizes.Select(index => estimatedValues[index]).ToList(); 89 90 88 this.chart.Series.Add(ESTIMATEDVALUES_ALL_SERIES_NAME); 91 89 this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].LegendText = ESTIMATEDVALUES_ALL_SERIES_NAME; 92 90 this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].ChartType = SeriesChartType.FastLine; 93 this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].EmptyPointStyle.Color = this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Color;94 91 this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(allIndizes, allEstimatedValues); 92 this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]); 95 93 this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Tag = Content; 96 94 this.ToggleSeriesData(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]); … … 98 96 UpdateCursorInterval(); 99 97 this.UpdateStripLines(); 98 } 99 } 100 101 private void InsertEmptyPoints(Series series) { 102 int i = 0; 103 while (i < series.Points.Count - 1) { 104 if (series.Points[i].IsEmpty) { 105 ++i; 106 continue; 107 } 108 109 var p1 = series.Points[i]; 110 var p2 = series.Points[i + 1]; 111 // check for consecutive indices 112 if ((int)p2.XValue - (int)p1.XValue != 1) { 113 // insert an empty point between p1 and p2 so that the line will be invisible (transparent) 114 var p = new DataPoint((int)((p1.XValue + p2.XValue) / 2), 0.0) { IsEmpty = true }; 115 series.Points.Insert(i + 1, p); 116 } 117 ++i; 100 118 } 101 119 } … … 200 218 if (series.Points.Count > 0) { //checks if series is shown 201 219 if (this.chart.Series.Any(s => s != series && s.Points.Count > 0)) { 202 series.Points.Clear();220 ClearPointsQuick(series.Points); 203 221 } 204 222 } else if (Content != null) { … … 223 241 } 224 242 series.Points.DataBindXY(indizes, predictedValues); 243 this.InsertEmptyPoints(series); 225 244 chart.Legends[series.Legend].ForeColor = Color.Black; 226 245 UpdateCursorInterval(); 227 246 chart.Refresh(); 228 247 } 248 } 249 250 // workaround as per http://stackoverflow.com/questions/5744930/datapointcollection-clear-performance 251 private static void ClearPointsQuick(DataPointCollection points) { 252 points.SuspendUpdates(); 253 while (points.Count > 0) 254 points.RemoveAt(points.Count - 1); 255 points.ResumeUpdates(); 229 256 } 230 257
Note: See TracChangeset
for help on using the changeset viewer.