Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChart.java @ 849:38c8cc586a85
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
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 21 Apr 2010 10:35:04 +0000 |
parents | 8b6ef091d38c |
children | 778d86255d76 |
line wrap: on
line diff
--- 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")) {