MPAndroidChart PieChart how to set label text?

前端 未结 5 565
忘了有多久
忘了有多久 2021-01-05 07:28

got the following code:

    Legend legend = mChart.getLegend();
    legend.setLabels(new String[]{\"aaaaa\", \"bbbbb\", \"ccccc\"});

This s

5条回答
  •  迷失自我
    2021-01-05 07:47

    Pass the label name as second parameter to constructor PieEntry(). (For version > 3.0.0)

    Example:

    ArrayList yvalues = new ArrayList();
    yvalues.add(new PieEntry(8f, "JAN"));
    yvalues.add(new PieEntry(15f, "FEB"));
    yvalues.add(new PieEntry(12f, "MAR"));
    yvalues.add(new PieEntry(25f, "APR"));
    yvalues.add(new PieEntry(23f, "MAY"));
    yvalues.add(new PieEntry(17f, "JUNE"));
    PieDataSet dataSet = new PieDataSet(yvalues, "Election Results");
    PieData data = new PieData();
    data.addDataSet(dataSet);
    data.setValueFormatter(new PercentFormatter());
    pieChart.setData(data);
    

提交回复
热议问题