comparison 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
comparison
equal deleted inserted replaced
848:47280aff0eb7 849:38c8cc586a85
192 localizeRangeAxis(yAxis, locale); 192 localizeRangeAxis(yAxis, locale);
193 193
194 // litte workarround to adjust the max range of axes. 194 // litte workarround to adjust the max range of axes.
195 // NumberAxis.setAutoRange(true) doesn't seem to work properly. 195 // NumberAxis.setAutoRange(true) doesn't seem to work properly.
196 Range yRange = (Range) ranges.get(seriesKey); 196 Range yRange = (Range) ranges.get(seriesKey);
197 yAxis.setRange(Range.expand(yRange, LOWER_MARGIN, UPPER_MARGIN)); 197 double lo = yRange.getLowerBound();
198 double hi = yRange.getUpperBound();
199
200 // XXX Special case: only a single value in this chart.
201 // JFreeChart doesn't expand this range, because its length is 0.
202 if (lo == hi) {
203 yRange = new Range(
204 lo - (lo / 100 * LOWER_MARGIN),
205 hi + (hi / 100 * UPPER_MARGIN));
206 }
207 else {
208 yRange = Range.expand(yRange, LOWER_MARGIN, UPPER_MARGIN);
209 }
210
211 yAxis.setRange(yRange);
198 log.debug("Max Range of dataset is: " + yRange.toString()); 212 log.debug("Max Range of dataset is: " + yRange.toString());
199 213
200 if (seriesKey.contains("richtung")) { 214 if (seriesKey.contains("richtung")) {
201 yAxis.setTickUnit(new NumberTickUnit(30.0)); 215 yAxis.setTickUnit(new NumberTickUnit(30.0));
202 yAxis.setUpperBound(360.0); 216 yAxis.setUpperBound(360.0);

http://dive4elements.wald.intevation.org