Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15619


Ignore:
Timestamp:
01/16/18 16:56:13 (7 years ago)
Author:
bburlacu
Message:

#2879: Performance improvement in DataTableView

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis.Views/3.3/DataTableView.cs

    r15583 r15619  
    398398        DataRow row = (DataRow)sender;
    399399        Series series = chart.Series[row.Name];
    400         series.Points.Clear();
     400        ClearPoints(series.Points);
    401401        ConfigureSeries(series, row);
    402402        if (!invisibleSeries.Contains(series)) {
     
    426426          Series rowSeries = chart.Series[row.Name];
    427427          if (!invisibleSeries.Contains(rowSeries)) {
    428             rowSeries.Points.Clear();
     428            ClearPoints(rowSeries.Points);
    429429            FillSeriesWithRowValues(rowSeries, row);
    430430            RecalculateAxesScale(chart.ChartAreas[0]);
     
    443443          Series rowSeries = chart.Series[row.Name];
    444444          if (!invisibleSeries.Contains(rowSeries)) {
    445             rowSeries.Points.Clear();
     445            ClearPoints(rowSeries.Points);
    446446            FillSeriesWithRowValues(rowSeries, row);
    447447            RecalculateAxesScale(chart.ChartAreas[0]);
     
    461461          if (!invisibleSeries.Contains(rowSeries)) {
    462462            if (row.VisualProperties.ChartType == DataRowVisualProperties.DataRowChartType.Histogram) {
    463               rowSeries.Points.Clear();
     463              ClearPoints(rowSeries.Points);
    464464              FillSeriesWithRowValues(rowSeries, row);
    465465            } else {
     
    488488          Series rowSeries = chart.Series[row.Name];
    489489          if (!invisibleSeries.Contains(rowSeries)) {
    490             rowSeries.Points.Clear();
     490            ClearPoints(rowSeries.Points);
    491491            FillSeriesWithRowValues(rowSeries, row);
    492492            RecalculateAxesScale(chart.ChartAreas[0]);
     
    506506          Series rowSeries = chart.Series[row.Name];
    507507          if (!invisibleSeries.Contains(rowSeries)) {
    508             rowSeries.Points.Clear();
     508            ClearPoints(rowSeries.Points);
    509509            FillSeriesWithRowValues(rowSeries, row);
    510510            RecalculateAxesScale(chart.ChartAreas[0]);
     
    549549    private void ToggleSeriesVisible(Series series) {
    550550      if (!invisibleSeries.Contains(series)) {
    551         series.Points.Clear();
     551        ClearPoints(series.Points);
    552552        invisibleSeries.Add(series);
    553553      } else {
     
    580580                            where !invisibleSeries.Contains(s)
    581581                            select new { row = r, series = s }) {
    582             h.series.Points.Clear();
     582            ClearPoints(h.series.Points);
    583583            CalculateHistogram(h.series, h.row, histograms);
    584584          }
     
    607607
    608608    protected virtual void CalculateHistogram(Series series, DataRow row, IEnumerable<DataRow> histogramRows) {
    609       series.Points.Clear();
     609      ClearPoints(series.Points);
    610610      if (!row.Values.Any()) return;
    611611
     
    740740      return double.IsNaN(x) || x < (double)decimal.MinValue || x > (double)decimal.MaxValue;
    741741    }
     742
     743    // workaround for performance problem as described in https://stackoverflow.com/questions/5744930/datapointcollection-clear-performance
     744    public static void ClearPoints(DataPointCollection points) {
     745      points.SuspendUpdates();
     746      while (points.Count > 0)
     747        points.RemoveAt(points.Count - 1);
     748      points.ResumeUpdates();
     749    }
    742750    #endregion
    743751  }
Note: See TracChangeset for help on using the changeset viewer.