我在我的应用程序中使用饼图,并使用以下库:
api 'com.github.PhilJay:MPAndroidChart:v3.0.3'
。
但我遇到了一个对齐问题。请查看以下截图:
代码:
public static void chartDetails(PieChart mChart, Typeface tf) {
mChart.animateXY(1400, 1400);
mChart.getDescription().setEnabled(false);
mChart.setCenterTextTypeface(tf);
mChart.setCenterText("");
mChart.setCenterTextSize(10f);
mChart.setCenterTextTypeface(tf);
// radius of the center hole in percent of maximum radius
mChart.setHoleRadius(45f);
mChart.setTransparentCircleRadius(50f);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
mChart.setTouchEnabled(true);
}
setDrawEntryLabels(false);
防止显示数据集的名称,如果要显示,请将其设置为true。setExtraOffsets(0.f, 5.f, 0.f, 5.f);
正如我刚刚编辑的那样,设置额外的填充以防止线条过长时被裁剪。您可以测试一些值,直到找到您喜欢的值。 - Marc Estrada