forked from PhilJay/MPAndroidChart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyValueFormatter.java
More file actions
35 lines (28 loc) · 957 Bytes
/
MyValueFormatter.java
File metadata and controls
35 lines (28 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.xxmassdeveloper.mpchartexample.custom;
import com.github.mikephil.charting.components.AxisBase;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.formatter.ValueFormatter;
import java.text.DecimalFormat;
public class MyValueFormatter extends ValueFormatter
{
private final DecimalFormat mFormat;
private String suffix;
public MyValueFormatter(String suffix) {
mFormat = new DecimalFormat("###,###,###,##0.0");
this.suffix = suffix;
}
@Override
public String getFormattedValue(float value) {
return mFormat.format(value) + suffix;
}
@Override
public String getAxisLabel(float value, AxisBase axis) {
if (axis instanceof XAxis) {
return mFormat.format(value);
} else if (value > 0) {
return mFormat.format(value) + suffix;
} else {
return mFormat.format(value);
}
}
}