changeset 1104:5207d09e4af6

Fixed range calculation for y-axes in the base chart class (issue233). gnv-artifacts/trunk@1234 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 28 Jun 2010 16:48:03 +0000 (2010-06-28)
parents faae3fc7b792
children 19813e72ec06
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/chart/AbstractXYLineChart.java
diffstat 2 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Mon Jun 28 10:48:57 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Mon Jun 28 16:48:03 2010 +0000
@@ -1,3 +1,11 @@
+2010-06-28  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	  Issue233
+
+	* src/main/java/de/intevation/gnv/chart/AbstractXYLineChart.java: Fixed
+	  the range calculation for y-axes if there is only a single datapoint
+	  existing in the chart.
+
 2010-06-28  Tim Englich  <tim.englich@intevation.de>
 
 	  Issue283: 
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/AbstractXYLineChart.java	Mon Jun 28 10:48:57 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/AbstractXYLineChart.java	Mon Jun 28 16:48:03 2010 +0000
@@ -207,7 +207,18 @@
         // 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();
+
+        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")) {

http://dive4elements.wald.intevation.org