Mercurial > dive4elements > river
changeset 3236:b0eee4c1eaa0
Implemented mergeRanges to combine y bounds in timeseries charts.
flys-artifacts/trunk@4867 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 03 Jul 2012 15:27:07 +0000 |
parents | 07231dcd5755 |
children | 1cad94fa0817 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java |
diffstat | 2 files changed, 39 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Tue Jul 03 15:22:53 2012 +0000 +++ b/flys-artifacts/ChangeLog Tue Jul 03 15:27:07 2012 +0000 @@ -1,3 +1,8 @@ +2012-07-03 Raimund Renkert <raimund.renkert@intevation.de> + + * src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java: + Implemented mergeRanges to combine y bounds in timeseries charts. + 2012-07-03 Raimund Renkert <raimund.renkert@intevation.de> * src/main/java/de/intevation/flys/exports/fixings/FixWQCurveInfoGenerator.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java Tue Jul 03 15:22:53 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java Tue Jul 03 15:27:07 2012 +0000 @@ -143,13 +143,42 @@ protected void mergeRanges(TimeSeriesCollection dataset) { - logger.debug("Range after merging: " + range); + logger.debug("Range before merging: " + range); + Range subRange = null; - Bounds[] xyRanges = ChartHelper.getBounds(dataset); + // Determine min/max of range axis. + for (int i = 0; i < dataset.getSeriesCount(); i++) { + double min = 0; + double max = 0; + TimeSeries series = dataset.getSeries(i); + for (int j = 0; j < series.getItemCount(); j++) { + double tmp = series.getValue(j).doubleValue(); + min = tmp < min ? tmp : min; + max = tmp > max ? tmp : max; + } + if (subRange != null) { + subRange = new Range( + min < subRange.getLowerBound() ? + min : subRange.getLowerBound(), + max > subRange.getUpperBound() ? + max : subRange.getUpperBound()); + } + else { + subRange = new Range(min, max); + } + } - // TODO COMBINE BOUNDS! - - logger.debug("Range after merging: " + range); + // Avoid merging NaNs, as they take min/max place forever. + if (subRange == null || + Double.isNaN(subRange.getLowerBound()) || + Double.isNaN(subRange.getUpperBound())) { + return; + } + if (range == null) { + range = subRange; + return; + } + range = Range.combine(range, subRange); } } // end of TimeseriesAxisDataset class