我正在使用MPAndroidChart。
我想删除PieChart上的百分比值。我怎样才能做到这一点?
答案 0 :(得分:10)
如果没有绘制条目值,请致电:
pieData.setDrawValues(false)
如果没有绘制x值,请致电:
pieChart.setDrawSliceText(false)
答案 1 :(得分:0)
看看下面的代码
PieEntry pe1 = new PieEntry(float_percent, stingdata);
entries.add(pe1);
total_values = total_values + float_percent;
No 2:
PieData data = new PieData(dataSet);
data.setValueFormatter(new MyValueFormatter(chart));
chart.setUsePercentValues(true);
enter code here
No 3:
class MyValueFormatter extends ValueFormatter
{
public DecimalFormat mFormat;
private PieChart pieChart;
public MyValueFormatter() {
mFormat = new DecimalFormat("###,###,##0.0");
}
// Can be used to remove percent signs if the chart isn't in percent mode
public MyValueFormatter(PieChart pieChart) {
this();
this.pieChart = pieChart;
}
@Override
public String getFormattedValue(float value) {
return mFormat.format(((total_values * value)/100)) + " %";
}
@Override
public String getPieLabel(float value, PieEntry pieEntry) {
if (pieChart != null && pieChart.isUsePercentValuesEnabled()) {
// Converted to percent
return getFormattedValue(value);
} else {
// raw value, skip percent sign
return mFormat.format(value);
}
}
}