MPAndroidChart PieChart how to set label text?

前端 未结 5 568
忘了有多久
忘了有多久 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 08:01

    I could not find the method setCustom(int[] color, String[] labels) in v3.0.0. Only setCustom(LegendEntry[]) for which you have to pass LegendEntry objects.

     List entries = new ArrayList<>();
    
     for (int i = 0; i < titleList.size(); i++) {
         LegendEntry entry = new LegendEntry();
         entry.formColor = colorList.get(i);
         entry.label = titleList.get(i);
         entries.add(entry);
     }
    
     legend.setCustom(entries);
    

提交回复
热议问题