Ignore:
Timestamp:
03/25/09 19:00:02 (11 years ago)
Author:
gkronber
Message:

Fixed tooltip bug in CEDMA BubbleChart. #543 (MouseDrag events in CEDMA BubbleChart cause 100% CPU utilization)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Charting/BubbleChart.cs

    r1287 r1424  
    118118      double maxSize = 1;
    119119      double minSize = 1;
    120       try {
    121         if (sizeDimension != null && results.OrdinalVariables.Contains(sizeDimension)) {
    122           var sizes = records
    123             .Select(x => Convert.ToDouble(x.Get(sizeDimension)))
    124             .Where(size => !double.IsInfinity(size) && size != double.MaxValue && size != double.MinValue)
    125             .OrderBy(r => r);
    126           minSize = sizes.ElementAt((int)(sizes.Count() * 0.1));
    127           maxSize = sizes.ElementAt((int)(sizes.Count() * 0.9));
    128         }
    129       }
    130       catch (InvalidCastException) {
     120      if (sizeDimension != null && results.OrdinalVariables.Contains(sizeDimension)) {
     121        var sizes = records
     122          .Select(x => Convert.ToDouble(x.Get(sizeDimension)))
     123          .Where(size => !double.IsInfinity(size) && size != double.MaxValue && size != double.MinValue)
     124          .OrderBy(r => r);
     125        minSize = sizes.ElementAt((int)(sizes.Count() * 0.1));
     126        maxSize = sizes.ElementAt((int)(sizes.Count() * 0.9));
     127      } else {
    131128        minSize = 1;
    132129        maxSize = 1;
     
    142139        double x, y;
    143140        int size;
    144         try {
     141        if (results.OrdinalVariables.Contains(xDimension)) {
    145142          x = Convert.ToDouble(r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor;
     143        } else if (results.CategoricalVariables.Contains(xDimension)) {
     144          x = results.IndexOfCategoricalValue(xDimension, r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor;
     145        } else {
     146          x = double.NaN;
     147        }
     148        if (results.OrdinalVariables.Contains(yDimension)) {
    146149          y = Convert.ToDouble(r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor;
    147           size = CalculateSize(Convert.ToDouble(r.Get(sizeDimension)), minSize, maxSize);
    148         }
    149         catch (InvalidCastException) {
    150           x = double.NaN;
     150        } else if (results.CategoricalVariables.Contains(yDimension)) {
     151          y = results.IndexOfCategoricalValue(yDimension, r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor;
     152        } else {
    151153          y = double.NaN;
    152           size = minBubbleSize;
    153         }
     154        }
     155        size = CalculateSize(Convert.ToDouble(r.Get(sizeDimension)), minSize, maxSize);
     156
    154157        if (double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN;
    155158        if (double.IsInfinity(y) || y == double.MaxValue || y == double.MinValue) y = double.NaN;
     
    221224    }
    222225
    223 
    224226    public override void MouseDrag(Point start, Point end, MouseButtons button) {
    225227      if (button == MouseButtons.Left && Mode == ChartMode.Select) {
     
    251253      if (button == MouseButtons.Left) {
    252254        ResultsEntry r = GetResultsEntry(point);
    253         if (r != null) r.ToggleSelected();
    254         results.FireChanged();
     255        if (r != null) {
     256          r.ToggleSelected();
     257          results.FireChanged();
     258        }
    255259      } else {
    256260        base.MouseClick(point, button);
Note: See TracChangeset for help on using the changeset viewer.