Free cookie consent management tool by TermsFeed Policy Generator

source: branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeInfluenceView.cs @ 10635

Last change on this file since 10635 was 10017, checked in by ascheibe, 11 years ago

#2031 improved sample size estimation and some minor improvements

File size: 22.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Windows.Forms;
26using System.Windows.Forms.DataVisualization.Charting;
27using HeuristicLab.Common;
28using HeuristicLab.Core;
29using HeuristicLab.Data;
30using HeuristicLab.MainForm;
31using HeuristicLab.MainForm.WindowsForms;
32using HeuristicLab.Optimization;
33using HeuristicLab.PluginInfrastructure;
34
35namespace HeuristicLab.Analysis.Statistics {
36  [View("Sample Size Influence")]
37  [Content(typeof(RunCollection), false)]
38  public partial class SampleSizeInfluenceView : AsynchronousContentView {
39    private enum AxisDimension { Color = 0 }
40    private const string BoxPlotSeriesName = "BoxPlotSeries";
41    private const string BoxPlotChartAreaName = "BoxPlotChartArea";
42
43    private bool suppressUpdates = false;
44    private string xAxisValue;
45    private string yAxisValue;
46    private Dictionary<int, Dictionary<object, double>> categoricalMapping;
47    private SortedDictionary<double, Series> seriesCache;
48
49    public SampleSizeInfluenceView() {
50      InitializeComponent();
51      categoricalMapping = new Dictionary<int, Dictionary<object, double>>();
52      seriesCache = new SortedDictionary<double, Series>();
53      chart.ChartAreas[0].Visible = false;
54      chart.Series.Clear();
55      chart.ChartAreas.Add(BoxPlotChartAreaName);
56      chart.CustomizeAllChartAreas();
57      chart.ChartAreas[BoxPlotChartAreaName].Axes.ToList().ForEach(x => { x.ScaleView.Zoomable = true; x.ScaleView.MinSize = 0; });
58      chart.ChartAreas[BoxPlotChartAreaName].CursorX.Interval = 0.5;
59      chart.ChartAreas[BoxPlotChartAreaName].CursorY.Interval = 1e-5;
60    }
61
62    public new RunCollection Content {
63      get { return (RunCollection)base.Content; }
64      set { base.Content = value; }
65    }
66    public IStringConvertibleMatrix Matrix {
67      get { return this.Content; }
68    }
69
70    #region RunCollection and Run events
71    protected override void RegisterContentEvents() {
72      base.RegisterContentEvents();
73      Content.Reset += new EventHandler(Content_Reset);
74      Content.ColumnNamesChanged += new EventHandler(Content_ColumnNamesChanged);
75      Content.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
76      Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
77      Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
78      Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);
79      Content.OptimizerNameChanged += new EventHandler(Content_AlgorithmNameChanged);
80      RegisterRunEvents(Content);
81    }
82    protected override void DeregisterContentEvents() {
83      base.DeregisterContentEvents();
84      Content.Reset -= new EventHandler(Content_Reset);
85      Content.ColumnNamesChanged -= new EventHandler(Content_ColumnNamesChanged);
86      Content.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
87      Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
88      Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
89      Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);
90      Content.OptimizerNameChanged -= new EventHandler(Content_AlgorithmNameChanged);
91      DeregisterRunEvents(Content);
92    }
93
94    protected virtual void RegisterRunEvents(IEnumerable<IRun> runs) {
95      foreach (IRun run in runs)
96        run.Changed += new EventHandler(run_Changed);
97    }
98    protected virtual void DeregisterRunEvents(IEnumerable<IRun> runs) {
99      foreach (IRun run in runs)
100        run.Changed -= new EventHandler(run_Changed);
101    }
102
103    private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
104      DeregisterRunEvents(e.OldItems);
105      RegisterRunEvents(e.Items);
106    }
107    private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
108      DeregisterRunEvents(e.Items);
109    }
110    private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
111      RegisterRunEvents(e.Items);
112    }
113    private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
114      if (InvokeRequired)
115        Invoke(new EventHandler(Content_UpdateOfRunsInProgressChanged), sender, e);
116      else {
117        suppressUpdates = Content.UpdateOfRunsInProgress;
118        if (!suppressUpdates) UpdateDataPoints();
119      }
120    }
121
122    private void Content_Reset(object sender, EventArgs e) {
123      if (InvokeRequired)
124        Invoke(new EventHandler(Content_Reset), sender, e);
125      else {
126        this.categoricalMapping.Clear();
127        UpdateDataPoints();
128        UpdateAxisLabels();
129      }
130    }
131    private void Content_ColumnNamesChanged(object sender, EventArgs e) {
132      if (InvokeRequired)
133        Invoke(new EventHandler(Content_ColumnNamesChanged), sender, e);
134      else {
135        UpdateComboBoxes();
136      }
137    }
138    private void run_Changed(object sender, EventArgs e) {
139      if (InvokeRequired)
140        this.Invoke(new EventHandler(run_Changed), sender, e);
141      else if (!suppressUpdates) {
142        UpdateDataPoints();
143      }
144    }
145
146    private void Content_AlgorithmNameChanged(object sender, EventArgs e) {
147      if (InvokeRequired)
148        Invoke(new EventHandler(Content_AlgorithmNameChanged), sender, e);
149      else UpdateCaption();
150    }
151    #endregion
152
153    #region update comboboxes, datapoints, runs
154    protected override void OnContentChanged() {
155      base.OnContentChanged();
156      this.categoricalMapping.Clear();
157      UpdateComboBoxes();
158      UpdateDataPoints();
159      UpdateCaption();
160    }
161
162    private void UpdateCaption() {
163      Caption = Content != null ? Content.OptimizerName + " Sample Size Influence" : ViewAttribute.GetViewName(GetType());
164    }
165
166    private void UpdateSampleSizes() {
167      string selectedYAxis = (string)this.yAxisComboBox.SelectedItem;
168
169      if (selectedYAxis != null && xAxisComboBox.Text.Trim() == string.Empty) {
170        List<double> values = new List<double>();
171        foreach (IRun run in Content.Where(x => x.Visible)) {
172          double? cv = GetValue(run, selectedYAxis);
173          if (cv.HasValue) {
174            values.Add(cv.Value);
175          }
176        }
177
178        if (values.Count() > 0) {
179          xAxisComboBox.Text = "1; ";
180          xAxisComboBox.Text += ((int)(values.Count() / 4)).ToString() + "; ";
181          xAxisComboBox.Text += ((int)(values.Count() / 2)).ToString() + "; ";
182          xAxisComboBox.Text += ((int)(values.Count() / 4 * 3)).ToString() + "; ";
183          xAxisComboBox.Text += ((int)(values.Count())).ToString();
184        }
185      }
186    }
187
188    private void UpdateComboBoxes() {
189      string selectedYAxis = (string)this.yAxisComboBox.SelectedItem;
190      this.xAxisComboBox.Text = string.Empty;
191      this.yAxisComboBox.Items.Clear();
192      if (Content != null) {
193        string[] additionalAxisDimension = Enum.GetNames(typeof(AxisDimension));
194        UpdateSampleSizes();
195        this.yAxisComboBox.Items.AddRange(additionalAxisDimension);
196        this.yAxisComboBox.Items.AddRange(Matrix.ColumnNames.ToArray());
197
198        bool changed = false;
199        if (selectedYAxis != null && yAxisComboBox.Items.Contains(selectedYAxis)) {
200          yAxisComboBox.SelectedItem = selectedYAxis;
201          changed = true;
202        }
203        if (changed)
204          UpdateDataPoints();
205      }
206    }
207
208    private void UpdateDataPoints() {
209      this.chart.Series.Clear();
210      this.seriesCache.Clear();
211      if (Content != null) {
212        var usableRuns = Content.Where(r => r.Visible).ToList();
213        Random rand = new Random();
214
215        List<int> groupSizes = ParseGroupSizesFromText(xAxisComboBox.Text);
216        foreach (int gs in groupSizes) {
217          int idx = gs;
218          List<IRun> runGroup = new List<IRun>();
219          if (idx > usableRuns.Count()) {
220            idx = usableRuns.Count();
221          }
222
223          for (int i = 0; i < idx; i++) {
224            int r = rand.Next(usableRuns.Count());
225            runGroup.Add(usableRuns[r]);
226          }
227          runGroup.ForEach(x => AddDataPoint(x, idx));
228        }
229
230        foreach (Series s in this.seriesCache.Values)
231          this.chart.Series.Add(s);
232
233        UpdateStatistics();
234        if (seriesCache.Count > 0) {
235          Series boxPlotSeries = CreateBoxPlotSeries();
236          this.chart.Series.Add(boxPlotSeries);
237        }
238
239        UpdateAxisLabels();
240        if (groupSizes.Any())
241          AddSampleSizeText();
242      } else {
243        sampleSizeTextBox.Text = string.Empty;
244      }
245      UpdateNoRunsVisibleLabel();
246    }
247
248    private void AddSampleSizeText() {
249      sampleSizeTextBox.Text = string.Empty;
250      var usableRuns = Content.Where(r => r.Visible).ToList();
251
252      if (!yAxisComboBox.DroppedDown)
253        this.yAxisValue = (string)yAxisComboBox.SelectedItem;
254
255      List<double?> yValue = usableRuns.Select(x => GetValue(x, this.yAxisValue)).ToList();
256      if (yValue.Any(x => !x.HasValue)) return;
257
258      double y = SampleSizeDetermination.DetermineSampleSizeByEstimatingMeanForLargeSampleSizes(yValue.Select(x => x.Value).ToArray());
259      sampleSizeTextBox.Text = y.ToString();
260    }
261
262    private List<int> ParseGroupSizesFromText(string groupsText, bool verbose = true) {
263      const string delimitor = ";";
264      string[] gs = groupsText.Split(delimitor.ToString().ToCharArray());
265      List<int> vals = new List<int>();
266
267      foreach (string s in gs) {
268        string ns = s.Trim();
269
270        if (ns != string.Empty) {
271          int v = 0;
272          try {
273            v = int.Parse(ns);
274            vals.Add(v);
275          }
276          catch (Exception ex) {
277            if (verbose) {
278              ErrorHandling.ShowErrorDialog("Can't parse group sizes. Please only use numbers seperated by a semicolon. ", ex);
279            }
280          }
281        }
282      }
283      return vals;
284    }
285
286    private void UpdateStatistics() {
287      DoubleMatrix matrix = new DoubleMatrix(11, seriesCache.Count);
288      matrix.SortableView = false;
289      List<string> columnNames = new List<string>();
290      foreach (Series series in seriesCache.Values) {
291        DataPoint datapoint = series.Points.FirstOrDefault();
292        if (datapoint != null) {
293          IRun run = (IRun)datapoint.Tag;
294          string selectedAxis = xAxisComboBox.Text;
295          IItem value = null;
296
297          if (Enum.IsDefined(typeof(AxisDimension), selectedAxis)) {
298            AxisDimension axisDimension = (AxisDimension)Enum.Parse(typeof(AxisDimension), selectedAxis);
299            switch (axisDimension) {
300              case AxisDimension.Color: value = new StringValue(run.Color.ToString());
301                break;
302            }
303          }
304
305          string columnName = string.Empty;
306          if (value != null && value is DoubleValue || value is IntValue) {
307            columnName = selectedAxis + ": ";
308            columnName += value.ToString();
309          } else {
310            columnName = series.Name;
311          }
312
313          columnNames.Add(columnName);
314        }
315      }
316      matrix.ColumnNames = columnNames;
317      matrix.RowNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Lower Confidence Int.", "Upper Confidence Int." };
318
319      for (int i = 0; i < seriesCache.Count; i++) {
320        Series series = seriesCache.ElementAt(i).Value;
321        double[] seriesValues = series.Points.Select(p => p.YValues[0]).OrderBy(d => d).ToArray();
322        Tuple<double, double> confIntervals = seriesValues.ConfidenceIntervals(0.95);
323        matrix[0, i] = seriesValues.Length;
324        matrix[1, i] = seriesValues.Min();
325        matrix[2, i] = seriesValues.Max();
326        matrix[3, i] = seriesValues.Average();
327        matrix[4, i] = seriesValues.Median();
328        matrix[5, i] = seriesValues.StandardDeviation();
329        matrix[6, i] = seriesValues.Variance();
330        matrix[7, i] = seriesValues.Percentile(0.25);
331        matrix[8, i] = seriesValues.Percentile(0.75);
332        matrix[9, i] = confIntervals.Item1;
333        matrix[10, i] = confIntervals.Item2;
334      }
335      statisticsMatrixView.Content = matrix;
336    }
337
338    private Series CreateBoxPlotSeries() {
339      Series boxPlotSeries = new Series(BoxPlotSeriesName);
340      string seriesNames = string.Concat(seriesCache.Keys.Select(x => x.ToString() + ";").ToArray());
341      seriesNames = seriesNames.Remove(seriesNames.Length - 1); //delete last ; from string
342
343      boxPlotSeries.ChartArea = BoxPlotChartAreaName;
344      boxPlotSeries.ChartType = SeriesChartType.BoxPlot;
345      boxPlotSeries["BoxPlotSeries"] = seriesNames;
346      boxPlotSeries["BoxPlotShowUnusualValues"] = "true";
347      boxPlotSeries["PointWidth"] = "0.4";
348      boxPlotSeries.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.VerticalCenter;
349      boxPlotSeries.BackSecondaryColor = System.Drawing.Color.FromArgb(130, 224, 64, 10);
350      boxPlotSeries.BorderColor = System.Drawing.Color.FromArgb(64, 64, 64);
351      boxPlotSeries.Color = System.Drawing.Color.FromArgb(224, 64, 10);
352
353      return boxPlotSeries;
354    }
355
356    private void AddDataPoint(IRun run, int idx) {
357      double xValue;
358      double? yValue;
359
360
361      this.xAxisValue = xAxisComboBox.Text;
362      if (!yAxisComboBox.DroppedDown)
363        this.yAxisValue = (string)yAxisComboBox.SelectedItem;
364
365      xValue = idx;
366      yValue = GetValue(run, this.yAxisValue);
367
368      if (yValue.HasValue) {
369        if (!this.seriesCache.ContainsKey(xValue))
370          seriesCache[xValue] = new Series(xValue.ToString());
371
372        Series series = seriesCache[xValue];
373        DataPoint point = new DataPoint(xValue, yValue.Value);
374        point.Tag = run;
375        series.Points.Add(point);
376      }
377    }
378    #endregion
379
380    #region get values from run
381    private double? GetValue(IRun run, string columnName) {
382      if (run == null || string.IsNullOrEmpty(columnName))
383        return null;
384
385      if (Enum.IsDefined(typeof(AxisDimension), columnName)) {
386        AxisDimension axisDimension = (AxisDimension)Enum.Parse(typeof(AxisDimension), columnName);
387        return GetValue(run, axisDimension);
388      } else {
389        int columnIndex = Matrix.ColumnNames.ToList().IndexOf(columnName);
390        IItem value = Content.GetValue(run, columnIndex);
391        if (value == null)
392          return null;
393
394        DoubleValue doubleValue = value as DoubleValue;
395        IntValue intValue = value as IntValue;
396        TimeSpanValue timeSpanValue = value as TimeSpanValue;
397        double? ret = null;
398        if (doubleValue != null) {
399          if (!double.IsNaN(doubleValue.Value) && !double.IsInfinity(doubleValue.Value))
400            ret = doubleValue.Value;
401        } else if (intValue != null)
402          ret = intValue.Value;
403        else if (timeSpanValue != null) {
404          ret = timeSpanValue.Value.TotalSeconds;
405        } else
406          ret = GetCategoricalValue(columnIndex, value.ToString());
407
408        return ret;
409      }
410    }
411    private double GetCategoricalValue(int dimension, string value) {
412      if (!this.categoricalMapping.ContainsKey(dimension)) {
413        this.categoricalMapping[dimension] = new Dictionary<object, double>();
414        var orderedCategories = Content.Where(r => r.Visible && Content.GetValue(r, dimension) != null).Select(r => Content.GetValue(r, dimension).ToString())
415
416                                       .Distinct().OrderBy(x => x, new NaturalStringComparer());
417        int count = 1;
418        foreach (var category in orderedCategories) {
419          this.categoricalMapping[dimension].Add(category, count);
420          count++;
421        }
422      }
423      return this.categoricalMapping[dimension][value];
424    }
425    private double GetValue(IRun run, AxisDimension axisDimension) {
426      double value = double.NaN;
427      switch (axisDimension) {
428        case AxisDimension.Color: {
429            value = GetCategoricalValue(-1, run.Color.ToString());
430            break;
431          }
432        default: {
433            throw new ArgumentException("No handling strategy for " + axisDimension.ToString() + " is defined.");
434          }
435      }
436      return value;
437    }
438    #endregion
439
440    #region GUI events
441    private void UpdateNoRunsVisibleLabel() {
442      if (this.chart.Series.Count > 0) {
443        noRunsLabel.Visible = false;
444        showStatisticsCheckBox.Enabled = true;
445        splitContainer.Panel2Collapsed = !showStatisticsCheckBox.Checked;
446      } else {
447        noRunsLabel.Visible = true;
448        showStatisticsCheckBox.Enabled = false;
449        splitContainer.Panel2Collapsed = true;
450      }
451    }
452
453    private void AxisComboBox_SelectedIndexChanged(object sender, EventArgs e) {
454      UpdateSampleSizes();
455      UpdateDataPoints();
456    }
457    private void UpdateAxisLabels() {
458      Axis xAxis = this.chart.ChartAreas[BoxPlotChartAreaName].AxisX;
459      Axis yAxis = this.chart.ChartAreas[BoxPlotChartAreaName].AxisY;
460      int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count();
461
462      SetCustomAxisLabels(xAxis, -1);
463      SetCustomAxisLabels(yAxis, yAxisComboBox.SelectedIndex - axisDimensionCount);
464
465      xAxis.Title = "Group Size";
466      if (yAxisComboBox.SelectedItem != null)
467        yAxis.Title = yAxisComboBox.SelectedItem.ToString();
468    }
469
470    private void chart_AxisViewChanged(object sender, System.Windows.Forms.DataVisualization.Charting.ViewEventArgs e) {
471      this.UpdateAxisLabels();
472    }
473
474    private void SetCustomAxisLabels(Axis axis, int dimension) {
475      axis.CustomLabels.Clear();
476      if (categoricalMapping.ContainsKey(dimension)) {
477        int position = 1;
478        foreach (var pair in categoricalMapping[dimension].Where(x => seriesCache.ContainsKey(x.Value))) {
479          string labelText = pair.Key.ToString();
480          CustomLabel label = new CustomLabel();
481          label.ToolTip = labelText;
482          if (labelText.Length > 25)
483            labelText = labelText.Substring(0, 25) + " ... ";
484          label.Text = labelText;
485          label.GridTicks = GridTickTypes.TickMark;
486          label.FromPosition = position - 0.5;
487          label.ToPosition = position + 0.5;
488          axis.CustomLabels.Add(label);
489          position++;
490        }
491      } else if (dimension > 0 && Content.GetValue(0, dimension) is TimeSpanValue) {
492        this.chart.ChartAreas[0].RecalculateAxesScale();
493        Axis correspondingAxis = this.chart.ChartAreas[0].Axes.Where(x => x.Name == axis.Name).SingleOrDefault();
494        if (correspondingAxis == null)
495          correspondingAxis = axis;
496        for (double i = correspondingAxis.Minimum; i <= correspondingAxis.Maximum; i += correspondingAxis.LabelStyle.Interval) {
497          TimeSpan time = TimeSpan.FromSeconds(i);
498          string x = string.Format("{0:00}:{1:00}:{2:00}", (int)time.Hours, time.Minutes, time.Seconds);
499          axis.CustomLabels.Add(i - correspondingAxis.LabelStyle.Interval / 2, i + correspondingAxis.LabelStyle.Interval / 2, x);
500        }
501      } else if (chart.ChartAreas[BoxPlotChartAreaName].AxisX == axis) {
502        double position = 1.0;
503        foreach (Series series in chart.Series) {
504          if (series.Name != BoxPlotSeriesName) {
505            string labelText = series.Points[0].XValue.ToString();
506            CustomLabel label = new CustomLabel();
507            label.FromPosition = position - 0.5;
508            label.ToPosition = position + 0.5;
509            label.GridTicks = GridTickTypes.TickMark;
510            label.Text = labelText;
511            axis.CustomLabels.Add(label);
512            position++;
513          }
514        }
515      }
516    }
517
518    private void chart_MouseMove(object sender, MouseEventArgs e) {
519      string newTooltipText = string.Empty;
520      string oldTooltipText;
521      HitTestResult h = this.chart.HitTest(e.X, e.Y);
522      if (h.ChartElementType == ChartElementType.AxisLabels) {
523        newTooltipText = ((CustomLabel)h.Object).ToolTip;
524      }
525
526      oldTooltipText = this.tooltip.GetToolTip(chart);
527      if (newTooltipText != oldTooltipText)
528        this.tooltip.SetToolTip(chart, newTooltipText);
529    }
530    #endregion
531
532    private void showStatisticsCheckBox_CheckedChanged(object sender, EventArgs e) {
533      splitContainer.Panel2Collapsed = !showStatisticsCheckBox.Checked;
534    }
535
536    private void defineSampleSizeButton_Click(object sender, EventArgs e) {
537      int min = 0, max = 0, step = 1;
538      var groupSizes = ParseGroupSizesFromText(xAxisComboBox.Text);
539      if (groupSizes.Count() > 0) {
540        min = groupSizes.Min();
541        max = groupSizes.Max();
542      }
543
544      using (var dialog = new DefineArithmeticProgressionDialog(true, min, max, step)) {
545        if (dialog.ShowDialog(this) == DialogResult.OK) {
546          var values = dialog.Values;
547          string newVals = "";
548          foreach (int v in values) {
549            newVals += v + "; ";
550          }
551          xAxisComboBox.Text = newVals;
552        }
553      }
554    }
555
556    private void xAxisComboBox_TextChanged(object sender, EventArgs e) {
557      var result = ParseGroupSizesFromText(xAxisComboBox.Text, false);
558
559      if (seriesCache.Count() == result.Count()) {
560        bool changed = false;
561        int i = 0;
562        foreach (var gs in seriesCache.Keys) {
563          if (((int)gs) != result[i]) {
564            changed = true;
565            break;
566          }
567          i++;
568        }
569
570        if (changed) {
571          UpdateDataPoints();
572        }
573      } else {
574        UpdateDataPoints();
575      }
576    }
577  }
578}
Note: See TracBrowser for help on using the repository browser.