Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/18/12 11:18:51 (12 years ago)
Author:
sforsten
Message:

#1758:

  • merged trunk r7330:8022 into branch
  • importButton shows a message, if clicked and it can't be used
Location:
branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views

  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.cs

    r7327 r8032  
    2626using System.Windows.Forms.DataVisualization.Charting;
    2727using HeuristicLab.MainForm;
    28 using HeuristicLab.MainForm.WindowsForms;
    2928
    3029namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    7271        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].LegendText = ESTIMATEDVALUES_TRAINING_SERIES_NAME;
    7372        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].ChartType = SeriesChartType.FastLine;
     73        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.Color = this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Color;
    7474        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]);
    7576        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Tag = Content;
    7677        // test series
     
    7980        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    8081        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]);
    8183        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Tag = Content;
    8284        // series of remaining points
     
    8486        var estimatedValues = Content.EstimatedValues.ToArray();
    8587        List<double> allEstimatedValues = allIndizes.Select(index => estimatedValues[index]).ToList();
    86 
    8788        this.chart.Series.Add(ESTIMATEDVALUES_ALL_SERIES_NAME);
    8889        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].LegendText = ESTIMATEDVALUES_ALL_SERIES_NAME;
    8990        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    9091        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(allIndizes, allEstimatedValues);
     92        this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]);
    9193        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Tag = Content;
    9294        this.ToggleSeriesData(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]);
     
    9496        UpdateCursorInterval();
    9597        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;
    96118      }
    97119    }
     
    196218      if (series.Points.Count > 0) {  //checks if series is shown
    197219        if (this.chart.Series.Any(s => s != series && s.Points.Count > 0)) {
    198           series.Points.Clear();
     220          ClearPointsQuick(series.Points);
    199221        }
    200222      } else if (Content != null) {
     
    219241        }
    220242        series.Points.DataBindXY(indizes, predictedValues);
    221         chart.DataManipulator.InsertEmptyPoints(1, IntervalType.Number, series.Name);
     243        this.InsertEmptyPoints(series);
    222244        chart.Legends[series.Legend].ForeColor = Color.Black;
    223245        UpdateCursorInterval();
    224246        chart.Refresh();
    225247      }
     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();
    226256    }
    227257
Note: See TracChangeset for help on using the changeset viewer.