Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/01/09 11:56:45 (15 years ago)
Author:
mstoeger
Message:

more "zoom level too high" fixes. the error also occured for empty charts and for empty data rows. #498

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/3.2/LineChart.cs

    r1980 r1987  
    398398
    399399    public void ZoomToFullView() {
    400       SetClipX(-0.1, model.MaxDataRowValues - 0.9);
     400      double xmin, xmax;
     401      GetClippingRange(0, model.MaxDataRowValues-1, out xmin, out xmax);
     402      SetClipX(xmin, xmax);
    401403
    402404      foreach (RowEntry rowEntry in rowEntries) {
    403405        YAxisDescriptor yAxis = rowEntry.DataRow.YAxis;
    404406
    405         double padding = (yAxis.MaxValue - yAxis.MinValue)*0.05;
    406 
    407         double ymin = yAxis.MinValue - padding;
    408         double ymax = yAxis.MaxValue + padding;
    409 
    410         if (Math.Abs(ymin-ymax) < double.Epsilon*5) {
    411           ymin -= 0.1;
    412           ymax += 0.1;
    413         }
    414 
     407        double ymin, ymax;
     408        GetClippingRange(yAxis.MinValue, yAxis.MaxValue, out ymin, out ymax);
    415409        SetClipY(rowEntry, ymin, ymax);
    416410      }
    417411
    418412      canvasUI.Invalidate();
     413    }
     414
     415    /// <summary>
     416    /// Calculates the required clipping range such that the specified min/max values
     417    /// visible including a small padding.
     418    /// </summary>
     419    /// <param name="minValue"></param>
     420    /// <param name="maxValue"></param>
     421    /// <param name="clipFrom"></param>
     422    /// <param name="clipTo"></param>
     423    private static void GetClippingRange(double minValue, double maxValue, out double clipFrom, out double clipTo) {
     424      if (minValue == double.MaxValue || maxValue == double.MinValue) {
     425        clipFrom = -0.1;
     426        clipTo = 1.1;
     427      } else {
     428        double padding = (maxValue - minValue)*0.05;
     429        clipFrom = minValue - padding;
     430        clipTo = maxValue + padding;
     431
     432        if (Math.Abs(clipTo - clipFrom) < double.Epsilon * 5) {
     433          clipFrom -= 0.1;
     434          clipTo += 0.1;
     435        }
     436      }
    419437    }
    420438
Note: See TracChangeset for help on using the changeset viewer.