Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#159 Fix bug in setMaximumDate/setMinimumDate

closed
David Gilbert
None
5
2007-04-27
2007-04-27
Owen Boyle
No

The org.jfree.chart.axis.DateAxis class contains two methods, setMinimumDate and setMaximumDate. These methods set the end-points of the plot's date axis. However, a problem arises, usually with an empty plot, when the new min is *later* than the existing max or when the new max is earlier than the existing min (a diagram would help here...)

In either case, it is possible to try to set the axis range with max < min. This throws an IllegalArgumentException in the range constructor:

Caused by: java.lang.IllegalArgumentException: Range(double, double): require lower (6.11284284E13) <= upper (1.0).
at org.jfree.data.Range.<init>(Range.java:89)
at org.jfree.data.time.DateRange.<init>(DateRange.java:83)
at org.jfree.chart.axis.DateAxis.setMinimumDate(DateAxis.java:563)

The fix, in each method, is to check the new value is not on the "wrong" side of the existing "other" value (ie, for minDate, the new min must not be after the existing max. For maxDate, the new max must not be before the existing min). If it is (in either case), both max and min are set to the same, new value. This makes a zero-length range, and avoids the exception.

Discussion

  • Owen Boyle
    Owen Boyle
    2007-04-27

    patch to org/jfree/chart/axis/DateAxis.java

     
    Attachments
  • David Gilbert
    David Gilbert
    2007-04-27

    • assigned_to: nobody --> mungady
    • status: open --> closed
     
  • David Gilbert
    David Gilbert
    2007-04-27

    Logged In: YES
    user_id=112975
    Originator: NO

    Thanks. I already applied a patch for this problem last week.

    Regards,

    Dave Gilbert
    JFreeChart Project Leader