File tree Expand file tree Collapse file tree
MPChartLib/src/main/java/com/github/mikephil/charting/formatter Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020public class LargeValueFormatter implements IValueFormatter , IAxisValueFormatter
2121{
2222
23- private static String [] SUFFIX = new String []{
23+ private String [] mSuffix = new String []{
2424 "" , "k" , "m" , "b" , "t"
2525 };
26- private static final int MAX_LENGTH = 5 ;
26+ private int mMaxLength = 5 ;
2727 private DecimalFormat mFormat ;
2828 private String mText = "" ;
2929
@@ -68,8 +68,12 @@ public void setAppendix(String appendix) {
6868 *
6969 * @param suff new suffix
7070 */
71- public void setSuffix (String [] suff ) {
72- SUFFIX = suff ;
71+ public void setSuffix (String [] suffix ) {
72+ this .mSuffix = suffix ;
73+ }
74+
75+ public void setMaxLength (int maxLength ) {
76+ this .mMaxLength = maxLength ;
7377 }
7478
7579 /**
@@ -84,9 +88,9 @@ private String makePretty(double number) {
8488 int numericValue2 = Character .getNumericValue (r .charAt (r .length () - 2 ));
8589 int combined = Integer .valueOf (numericValue2 + "" + numericValue1 );
8690
87- r = r .replaceAll ("E[0-9][0-9]" , SUFFIX [combined / 3 ]);
91+ r = r .replaceAll ("E[0-9][0-9]" , mSuffix [combined / 3 ]);
8892
89- while (r .length () > MAX_LENGTH || r .matches ("[0-9]+\\ .[a-z]" )) {
93+ while (r .length () > mMaxLength || r .matches ("[0-9]+\\ .[a-z]" )) {
9094 r = r .substring (0 , r .length () - 2 ) + r .substring (r .length () - 1 );
9195 }
9296
You can’t perform that action at this time.
0 commit comments