Mercurial > dive4elements > river
changeset 5673:e1ba8273df07
Add saveguard not to include 0 in a scale for logarithmic axes
Including 0 or allowing negative values triggers a bug in the
jfreechart logarithmic axis code that causes values < 1 to be
drawn in carthesic coordinates.
Fixes:
flys/issue12345
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 12 Apr 2013 12:23:53 +0200 (2013-04-12) |
parents | c2a590925ec3 |
children | c6a6ef2d4e7e |
files | flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java Fri Apr 12 12:22:01 2013 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/DoubleBounds.java Fri Apr 12 12:23:53 2013 +0200 @@ -2,6 +2,7 @@ import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.axis.LogarithmicAxis; import org.jfree.data.Range; @@ -50,7 +51,12 @@ @Override public void applyBounds(ValueAxis axis, int percent) { double space = (upper - lower) / 100 * percent; - axis.setRange(new Range(lower-space, upper+space)); + if (axis instanceof LogarithmicAxis) { + axis.setRange(new Range(Math.max(lower-space, 0.0001), + Math.max(upper+space, 0.0002))); + } else { + axis.setRange(new Range(lower-space, upper+space)); + } }