aboutsummaryrefslogtreecommitdiff
path: root/MPChartLib/src/main/java/com/github
diff options
context:
space:
mode:
authorMaxim Pestryakov <MaximPestryakov@users.noreply.github.com>2017-10-06 17:12:46 +0300
committerGitHub <noreply@github.com>2017-10-06 17:12:46 +0300
commitd3c339da100f874f7df8d350bc46dd516ad1d577 (patch)
treed5d90901d213db7a4600fd9ad08dd9aab561d456 /MPChartLib/src/main/java/com/github
parent72031d33cacf9d880261e491a5de6f0c1b2de78d (diff)
downloadMPAndroidChart-d3c339da100f874f7df8d350bc46dd516ad1d577.tar.gz
Refactored LargeValueFormatter
Diffstat (limited to 'MPChartLib/src/main/java/com/github')
-rw-r--r--MPChartLib/src/main/java/com/github/mikephil/charting/formatter/LargeValueFormatter.java16
1 files changed, 10 insertions, 6 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..01eae56f 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 = "";
@@ -68,8 +68,12 @@ public class LargeValueFormatter implements IValueFormatter, IAxisValueFormatter
*
* @param suff 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);
}