Reputation: 17
I am working with "implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3' " this library for creating pie chart and the Pie Entry values which I entered manually is not appearing as correctly. I follow the tutorial and the results in the tutorials were also like that not appearing the correct values.
PieChart pieChart=findViewById(R.id.pieChart);
pieChart.setUsePercentValues(true);
pieChart.getDescription().setEnabled(false);
pieChart.setExtraOffsets(5,10,5,10);
pieChart.setDragDecelerationFrictionCoef(0.95f); //how smooth it should spin
pieChart.setDrawHoleEnabled(true);
pieChart.setHoleColor(Color.WHITE);
pieChart.setTransparentCircleRadius(60f);
List<PieEntry> value=new ArrayList<>();
value.add(new PieEntry(23.2f,"value1");
value.add(new PieEntry(92.2f,"value2");
value.add(new PieEntry(12.3f,"value3");
PieDataSet pieDataSet= new PieDataSet(value,"Months");
pieDataSet.setSliceSpace(3f); //between the slice spaces
pieDataSet.setSelectionShift(5f);
pieDataSet.setColors(ColorTemplate.MATERIAL_COLORS); //for variety of colors
PieData pieData=new PieData(pieDataSet);
pieData.setValueTextSize(10f);
pieData.setValueTextColors(Collections.singletonList(Color.WHITE));
pieChart.animateXY(1400,1400);
pieChart.setData(pieData);
23.2f is appearing as 18.2, 92.2f is appearing as 72.2 and 12.3 is appearing as 9.6 why the values don't appear as I have mentioned?
Upvotes: 0
Views: 182
Reputation: 1069
Its showing percentage value of pie chart.
please make it false to show real value. like below
pieChart.setUsePercentValues(false);
Upvotes: 3