-
- All Implemented Interfaces:
-
com.github.mikephil.charting.formatter.IAxisValueFormatter,com.github.mikephil.charting.formatter.IValueFormatter
public class LargeValueFormatter implements IValueFormatter, IAxisValueFormatter
Predefined value-formatter that formats large numbers in a pretty way. Outputs: 856 = 856; 1000 = 1k; 5821 = 5.8k; 10500 = 10k; 101800 = 102k; 2000000 = 2m; 7800000 = 7.8m; 92150000 = 92m; 123200000 = 123m; 9999999 = 10m; 1000000000 = 1b; Special thanks to Roman Gromov (https://github.com/romangromov) for this piece of code.
-
-
Constructor Summary
Constructors Constructor Description LargeValueFormatter(String appendix)Creates a formatter that appends a specified text to the result string LargeValueFormatter()
-
Method Summary
Modifier and Type Method Description StringgetFormattedValue(Float value, Entry entry, Integer dataSetIndex, ViewPortHandler viewPortHandler)Called when a value (from labels inside the chart) is formatted before being drawn. StringgetFormattedValue(Float value, AxisBase axis)Called when a value from an axis is to be formatted before being drawn. final UnitsetAppendix(String appendix)Set an appendix text to be added at the end of the formatted value. final UnitsetSuffix(Array<String> suffixArray)Set custom suffix to be appended after the values. final UnitsetMaxLength(Integer max)-
-
Constructor Detail
-
LargeValueFormatter
LargeValueFormatter(String appendix)
Creates a formatter that appends a specified text to the result string- Parameters:
appendix- a text that will be appended
-
LargeValueFormatter
LargeValueFormatter()
-
-
Method Detail
-
getFormattedValue
String getFormattedValue(Float value, Entry entry, Integer dataSetIndex, ViewPortHandler viewPortHandler)
Called when a value (from labels inside the chart) is formatted before being drawn. For performance reasons, avoid excessive calculations and memory allocations inside this method.
- Parameters:
value- the value to be formattedentry- the entry the value belongs to - in e.g.dataSetIndex- the index of the DataSet the entry in focus belongs toviewPortHandler- provides information about the current chart state (scale, translation, ...
-
getFormattedValue
String getFormattedValue(Float value, AxisBase axis)
Called when a value from an axis is to be formatted before being drawn. For performance reasons, avoid excessive calculations and memory allocations inside this method.
- Parameters:
value- the value to be formattedaxis- the axis the value belongs to
-
setAppendix
final Unit setAppendix(String appendix)
Set an appendix text to be added at the end of the formatted value.
-
setSuffix
final Unit setSuffix(Array<String> suffixArray)
Set custom suffix to be appended after the values. Default suffix: "", "k", "m", "b", "t"
- Parameters:
suffixArray- new suffix
-
setMaxLength
final Unit setMaxLength(Integer max)
-
-
-
-