use of com.github.mikephil.charting.formatter.PercentFormatter in project MPAndroidChart by PhilJay.
the class PieChartItem method getView.
@Override
public View getView(int position, View convertView, Context c) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(c).inflate(R.layout.list_item_piechart, null);
holder.chart = (PieChart) convertView.findViewById(R.id.chart);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// apply styling
holder.chart.getDescription().setEnabled(false);
holder.chart.setHoleRadius(52f);
holder.chart.setTransparentCircleRadius(57f);
holder.chart.setCenterText(mCenterText);
holder.chart.setCenterTextTypeface(mTf);
holder.chart.setCenterTextSize(9f);
holder.chart.setUsePercentValues(true);
holder.chart.setExtraOffsets(5, 10, 50, 10);
mChartData.setValueFormatter(new PercentFormatter());
mChartData.setValueTypeface(mTf);
mChartData.setValueTextSize(11f);
mChartData.setValueTextColor(Color.WHITE);
// set data
holder.chart.setData((PieData) mChartData);
Legend l = holder.chart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setYEntrySpace(0f);
l.setYOffset(0f);
// do not forget to refresh the chart
// holder.chart.invalidate();
holder.chart.animateY(900);
return convertView;
}
Aggregations