我正在使用MPAndroidChart,我正在尝试使用mpandroidchart lib创建一个看起来像甜甜圈的饼图,但不知怎的,我无法做到这一点.
以下是我的代码 –
ArrayList<Entry> entries = new ArrayList<>();
entries.add(new Entry((float) 20.0, 0));
entries.add(new Entry((float) 30.0, 1));
int colors[] = {Color.parseColor("#DCDEE0"),Color.parseColor("#466A80"),Color.parseColor("#0078CA"),Color.parseColor("#5BC2E7"),Color.parseColor("#99E4FF")};
PieDataSet dataset = new PieDataSet(entries, "# of Calls");
dataset.setColors(colors);
dataset.setSliceSpace(3f);
ArrayList<String> labels = new ArrayList<String>();
labels.add("January");
labels.add("February");
/* labels.add("March");
labels.add("April");
labels.add("May");
labels.add("June");*/
PieChart chart1 = new PieChart(this);
chart1.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0.5f));
chart1.setHoleRadius(60f);
chart1.setHoleColorTransparent(false);
chart1.setDrawHoleEnabled(true);
chart1.setUsePercentValues(true);
chart1.setHoleColor(Color.WHITE);
PieChart chart2 = new PieChart(this);
chart2.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0.5f));
LinearLayout chart = (LinearLayout)findViewById(R.id.chart);
chart.addView(chart1);
chart.addView(chart2);
PieData data = new PieData(labels, dataset);
chart1.setData(data);
chart2.setData(data);
我能够绘制饼图,但不能使它看起来像甜甜圈.请参阅附加的屏幕截图.有人可以请帮助.
解决方法:
这是已知问题,已在最新提交中修复.
https://github.com/PhilJay/MPAndroidChart/issues/527
包含修复程序的库的v2.1.0应该在下周内发布!