MPAndroidChart PieChart如何设置标签文字? [英] MPAndroidChart PieChart how to set label text?

查看:123
本文介绍了MPAndroidChart PieChart如何设置标签文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获得以下代码:

    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.

legend.setEnabled(true);

使用com.github.PhilJay:MPAndroidChart:v3.0.0:-

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

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

setCustom(int [] colors,String [] labels):设置自定义图例的标签和颜色数组.颜色计数应与标签计数匹配.每种颜色都是针对在相同索引处绘制的表单.

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.

这篇关于MPAndroidChart PieChart如何设置标签文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆