abhishek abhishek - 4 months ago 58
Android Question

MPAndroid Pie Chart Remove decimal percentages and not show value for values less than 10%

1)MPAndroid Pie Chart Remove decimal percentages
2) Not show values on the Pie Chart that have values less than 10%, but show the slice; just the text should not be shown for the percentages less than 10%.


This is a job for the ValueFormatter.

public class MyValueFormatter implements ValueFormatter {

    private DecimalFormat mFormat;

    public MyValueFormatter() {
        mFormat = new DecimalFormat("###,###,###"); // use no decimals

    public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {

        // write your logic here
        if(value < 10) return "";

        return mFormat.format(value);

Set the formatter to your dataset:

pieDataSet.setValueFormatter(new MyValueFormatter());

In addition, disable the conversion to percent: