Android中的Mpchartlib从饼图中删除切片文本

时间:2015-10-12 12:57:22

标签: android pie-chart

enter image description here

HI .. 我使用https://github.com/PhilJay/MPAndroidChart在我的应用程序中显示饼图。我想隐藏图像中白色方块显示的部分。

我使用了以下代码..

 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);

我设置数据的方法是......

  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();



}

任何人都可以帮我隐藏这些价值吗?谢谢你的帮助。

4 个答案:

答案 0 :(得分:3)

pieChart.setDrawSliceText(false)可以移除xVals pieChart.getData().setDrawValues(false)可以删除yVals

答案 1 :(得分:2)

要删除切片文本(来自x值数组),请调用:

pieChart.setDrawSliceText(false)

答案 2 :(得分:2)

PieDataSet dataSet = new PieDataSet(values, "xyz");
dataSet.setDrawValues(false); // It removes text from chart

答案 3 :(得分:0)

pieChart.setDrawSliceText(false)已过时,请改用setDrawEntryLabels(...)。

pieChart.setDrawEntryLabels(false)