Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mpchartlib in Android remove slice text from piechart

enter image description here

HI.. I have used https://github.com/PhilJay/MPAndroidChart to display piechart in my application. I want to hide portion displayed in white square in image.

I have used following code..

 mChart.setDescription("");
        mChart.setDrawCenterText(true);
        mChart.setDrawHoleEnabled(false);
        mChart.setRotationAngle(90);
        mChart.setRotationEnabled(false);
        mChart.setTouchEnabled(false);
        mChart.setCenterText(PTGConstantMethod.getNumberInTwoDigit((float) total));
        mChart.setCenterTextTypeface(fontBold);
        mChart.setCenterTextSize(getResources().getDimension(R.dimen.text_rate_circle_size));
        mChart.setDrawHoleEnabled(true);
        mChart.setDrawSliceText(false);
        setChartData(aryVals, total);



        mChart.animateXY(1000, 1000);

        mChart.getLegend().setEnabled(false);

And my method to set data is..

  private void setChartData(float[] values,double total) {

    ArrayList<Entry> yVals = new ArrayList<Entry>();

    for (int i = 0; i < values.length; i++) {
        yVals.add(new Entry(values[i], i));
    }

    ArrayList<String> xVals = new ArrayList<String>();

    for (int i = 0; i < values.length; i++) {
        xVals.add("");
    }


    PieDataSet set1 = new PieDataSet(yVals, "");
    set1.setSliceSpace(0);

    ArrayList<Integer> colors = new ArrayList<Integer>();

    colors.add(Color.parseColor("#d9534f"));
    colors.add(Color.parseColor("#009a20"));
    colors.add(Color.parseColor("#5bc0de"));
    set1.setColors(colors);

    PieData data = new PieData(xVals,set1);

    mChart.setData(data);
    mChart.highlightValues(null);
    mChart.invalidate();



}

Anyone can help me to hide these value? Thanks for your help.

like image 578
Beena Avatar asked Mar 15 '23 12:03

Beena


2 Answers

pieChart.setDrawSliceText(false) can remove the xVals pieChart.getData().setDrawValues(false) can remove the yVals

like image 90
Freddy Avatar answered Mar 17 '23 02:03

Freddy


To remove the slice text (coming from the x-values array), call:

pieChart.setDrawSliceText(false)

like image 40
Philipp Jahoda Avatar answered Mar 17 '23 01:03

Philipp Jahoda