diff options
author | Mick A <mick.ashton@flare-esports.net> | 2018-05-09 09:07:06 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-09 09:07:06 -0600 |
commit | 53de181607d0d3376acc035cca70b7bb9b806731 (patch) | |
tree | 87b9db0499f03c9445ce10910275f754a005e150 /MPChartLib/src/main/java/com | |
parent | 9ee3a74633266b7ba4c8323c82a0ed48c3ce8253 (diff) | |
parent | 5869c9de23bf46eb36631a1dcc2785fe6f0e19f0 (diff) | |
download | MPAndroidChart-53de181607d0d3376acc035cca70b7bb9b806731.tar.gz |
Merge pull request #3478 from MaximPestryakov/patch-1
Refactored LargeValueFormatter
Diffstat (limited to 'MPChartLib/src/main/java/com')
-rw-r--r-- | MPChartLib/src/main/java/com/github/mikephil/charting/formatter/LargeValueFormatter.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/LargeValueFormatter.java b/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/LargeValueFormatter.java index c950d640..211401ad 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/LargeValueFormatter.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/formatter/LargeValueFormatter.java @@ -20,10 +20,10 @@ import java.text.DecimalFormat; public class LargeValueFormatter implements IValueFormatter, IAxisValueFormatter { - private static String[] SUFFIX = new String[]{ + private String[] mSuffix = new String[]{ "", "k", "m", "b", "t" }; - private static final int MAX_LENGTH = 5; + private int mMaxLength = 5; private DecimalFormat mFormat; private String mText = ""; @@ -66,10 +66,14 @@ public class LargeValueFormatter implements IValueFormatter, IAxisValueFormatter * Set custom suffix to be appended after the values. * Default suffix: ["", "k", "m", "b", "t"] * - * @param suff new suffix + * @param suffix new suffix */ - public void setSuffix(String[] suff) { - SUFFIX = suff; + public void setSuffix(String[] suffix) { + this.mSuffix = suffix; + } + + public void setMaxLength(int maxLength) { + this.mMaxLength = maxLength; } /** @@ -84,9 +88,9 @@ public class LargeValueFormatter implements IValueFormatter, IAxisValueFormatter int numericValue2 = Character.getNumericValue(r.charAt(r.length() - 2)); int combined = Integer.valueOf(numericValue2 + "" + numericValue1); - r = r.replaceAll("E[0-9][0-9]", SUFFIX[combined / 3]); + r = r.replaceAll("E[0-9][0-9]", mSuffix[combined / 3]); - while (r.length() > MAX_LENGTH || r.matches("[0-9]+\\.[a-z]")) { + while (r.length() > mMaxLength || r.matches("[0-9]+\\.[a-z]")) { r = r.substring(0, r.length() - 2) + r.substring(r.length() - 1); } |