I am trying to show a bar grpah (MPAndroidChart) which has values in decimal. but the graph shows them without decimal. My code for value formatter looks like this:
protected class MyValueFormatter implements ValueFormatter{
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
Log.d(Constants.TAG,"Initial value == "+value+" == "+entry.getVal());
DecimalFormat df = new DecimalFormat("#.###");
df.setRoundingMode(RoundingMode.CEILING);
Log.d(Constants.TAG,"Formatted value == "+df.format(value));
return df.format((double)value);
}
}
Following is the data used to draw the graph chart
"data":[[16003376.986129051,10003344],[25089516.75475807,20089516],[39517705.32395167,30517705],[2490973.063333333,3090973]]
Following is the value formatter log
Initial value == 1.6003376E7 == 1.6003376E7
Formatted value == 16003376
Initial value == 1.0003344E7 == 1.0003344E7
Formatted value == 10003344
Initial value == 1.6003376E7 == 1.6003376E7
Formatted value == 16003376
Initial value == 1.0003344E7 == 1.0003344E7
......many more
My concern is:
- The original value is converted from 16003376.986129051 to 1.6003376E7
- Graph shows value on top of the bar as 16003376, since decimal handling is not implemented yet
- How do i get the original value to convert it into 3 decimal figure since the decimal values are very important from financial point of view