Hello Phil,
I just wanna say thanks for the library.. It's awesome.
I'm having a weird issue when adding just 1 item to the PieChart, when it finishes the animation the slice just becomes transparent with the label still visible as 100 %.
this is my implementation:
public class PieChartConstructor {
private static PieChart mChart;
public static PieChart construct(PieChart chart, ArrayList<Summary> items, SpannableString centerText) {
mChart = chart;
mChart.setUsePercentValues(true);
mChart.setDescription("");
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
mChart.setDrawHoleEnabled(true);
mChart.setHoleColor(Color.WHITE);
mChart.setHoleRadius(75f);
mChart.setDrawCenterText(true);
mChart.setRotationAngle(0);
mChart.setRotationEnabled(true);
mChart.setHighlightPerTapEnabled(true);
setData(items);
return mChart;
}
private static void setData(ArrayList<Summary> items) {
ArrayList<com.github.mikephil.charting.data.Entry> yVals1 = new ArrayList<com.github.mikephil.charting.data.Entry>();
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<Integer> colors = new ArrayList<Integer>();
for (int i = 0; i < items.size(); i++) {
yVals1.add(new com.github.mikephil.charting.data.Entry(Float.parseFloat(items.get(i).total + ""), i));
xVals.add("");
colors.add(Color.parseColor(items.get(i).category.getColor()));
}
PieDataSet dataSet = new PieDataSet(yVals1, "Savings");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(5f);
dataSet.setColors(colors);
PieData data = new PieData(xVals, dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(11f);
data.setValueTextColor(Color.WHITE);
mChart.setData(data);
mChart.highlightValues(null);
mChart.getLegend().setEnabled(false);
mChart.invalidate();
}
}
Thanks
Post your build.gradle file please
compile 'com.github.PhilJay:MPAndroidChart:v2.2.3'
update to v2.2.4
done and worked.. thank you
It worked for me. Thanks o/
Thanks, works for me after updating to 2.2.4
Most helpful comment
update to v2.2.4