[Java] 纯文本查看 复制代码
ColorTemplate mCt;
mCt = new ColorTemplate();
mCt.addDataSetColors(ColorTemplate.PASTEL_COLORS, this);
mChart = (PieChart) headView.findViewById(R.id.spread_pie_chart);
mChart.setColorTemplate(mCt);
mChart.setDescription("");
mChart.setHoleRadius(30f);
mChart.setTransparentCircleRadius(0f);
mChart.setCenterTextSize(18f);
mChart.setDrawXValues(true);
mChart.setUsePercentValues(true);
mChart.setDrawLegend(false);
// space between slices
mChart.setSliceSpace(1f);
mChart.setDrawHoleEnabled(false);
mChart.setTouchEnabled(false);
[Java] 纯文本查看 复制代码
ArrayList<Entry> yVals = new ArrayList<Entry>();
ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < listDatas.size(); i++) {
yVals.add(new Entry((float)listDatas.get(i).getProvinceCount(), i));
xVals.add(listDatas.get(i).getProvinceName());
}
DataSet set1 = new DataSet(yVals, "Content");
ArrayList<DataSet> dataSets = new ArrayList<DataSet>();
dataSets.add(set1);
ChartData data = new ChartData(xVals, dataSets);
mChart.setData(data);