Fomove Fomove - 3 months ago 44
Android Question

MPAndroidChart PieChart how to set label text?

got the following code:

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

This setting does not take effect Is there an other way to set the text ?


You can set custom labels with colors:

First make sure Legend is enable. Unless enable legend.


With com.github.PhilJay:MPAndroidChart:v3.0.0:-

legend .setCustom(ColorTemplate.VORDIPLOM_COLORS, new String[] { "aaaaa", "bbbbb", "ccccc"});

setCustom(int[] colors, String[] labels): Sets a custom legend's labels and colors arrays. The colors count should match the labels count. Each color is for the form drawn at the same index.