# HG changeset patch # User Ingo Weinzierl # Date 1271846104 0 # Node ID 38c8cc586a85952c2504243c2eac1e3e3b7d67a9 # Parent 47280aff0eb76750aae148e8b44072bacec758d2 Expand the range of a horizontalprofile chart manually if there is only a single data point or more data points with all the same value in this chart (issue233). gnv-artifacts/trunk@965 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 47280aff0eb7 -r 38c8cc586a85 gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Wed Apr 21 09:43:46 2010 +0000 +++ b/gnv-artifacts/ChangeLog Wed Apr 21 10:35:04 2010 +0000 @@ -1,3 +1,11 @@ +2010-04-21 Ingo Weinzierl + + Issue233 + + * src/main/java/de/intevation/gnv/chart/HorizontalProfileChart.java: Expand + the range of the range axis (y-axis) manually if there is only one data + point or more data points with the same value. + 2010-04-21 Ingo Weinzierl Issue243 diff -r 47280aff0eb7 -r 38c8cc586a85 gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChart.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChart.java Wed Apr 21 09:43:46 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChart.java Wed Apr 21 10:35:04 2010 +0000 @@ -194,7 +194,21 @@ // litte workarround to adjust the max range of axes. // NumberAxis.setAutoRange(true) doesn't seem to work properly. Range yRange = (Range) ranges.get(seriesKey); - yAxis.setRange(Range.expand(yRange, LOWER_MARGIN, UPPER_MARGIN)); + double lo = yRange.getLowerBound(); + double hi = yRange.getUpperBound(); + + // XXX Special case: only a single value in this chart. + // JFreeChart doesn't expand this range, because its length is 0. + if (lo == hi) { + yRange = new Range( + lo - (lo / 100 * LOWER_MARGIN), + hi + (hi / 100 * UPPER_MARGIN)); + } + else { + yRange = Range.expand(yRange, LOWER_MARGIN, UPPER_MARGIN); + } + + yAxis.setRange(yRange); log.debug("Max Range of dataset is: " + yRange.toString()); if (seriesKey.contains("richtung")) {