#159 Fix bug in setMaximumDate/setMinimumDate


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.


  • Anonymous - 2007-04-27

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

  • David Gilbert

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

    David Gilbert - 2007-04-27

    Logged In: YES
    Originator: NO

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


    Dave Gilbert
    JFreeChart Project Leader


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks