Skip to content
Snippets Groups Projects
Commit 40fe91c7 authored by Tim Molter's avatar Tim Molter
Browse files

fixed zero formatting bug

parent 1b49305b
No related branches found
No related tags found
No related merge requests found
......@@ -70,7 +70,7 @@ public class AxisValueFormatterUtil {
BigDecimal absoluteValue = value.abs();
if (absoluteValue.compareTo(new BigDecimal("10000")) == -1 && absoluteValue.compareTo(new BigDecimal(".0001")) == 1 || absoluteValue.equals(new BigDecimal("0.0"))) {
if (absoluteValue.compareTo(new BigDecimal("10000")) == -1 && absoluteValue.compareTo(new BigDecimal(".0001")) == 1 || BigDecimal.ZERO.compareTo(value) == 0) {
DecimalFormat normalFormat = (DecimalFormat) numberFormat;
normalFormat.applyPattern(normalDecimalPatternOverride == null ? NORMAL_DECIMAL_PATTERN : normalDecimalPatternOverride);
......
......@@ -78,6 +78,14 @@ public class ValueFormatTest {
stringValue = AxisValueFormatterUtil.formatNumber(value, null, null, locale);
assertThat(stringValue, equalTo("1E-4"));
value = new BigDecimal("0.0");
stringValue = AxisValueFormatterUtil.formatNumber(value, null, null, locale);
assertThat(stringValue, equalTo("0"));
value = new BigDecimal("0");
stringValue = AxisValueFormatterUtil.formatNumber(value, null, null, locale);
assertThat(stringValue, equalTo("0"));
// other case
// TODO handle these cases better
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment