Pie Chart label text outside slice overlaps with value line.
Hi,
While working with a pie charts I found out that if you are drawing labels(only) outside the slices the text of labels overlaps with the value line. I just commented this
dataSet.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
in https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/PiePolylineChartActivity.java:

Please let me know if there is a setting for setting label text offset. As a workaround I've set offset in drawValues to labelRadius/2 instead of 5.f but I guess that will might mess other things up.
This still appears to be broke on 3.0.0-beta1
Also once moving to outside slice value text color only shows white.
data.setValueTextColor(Color.BLACK); dataSet.setValueLinePart1OffsetPercentage(90.f); dataSet.setValueLinePart1Length(1f); dataSet.setValueLinePart2Length(.2f); dataSet.setValueTextColor(Color.BLACK); dataSet.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
@anshchauhan How did you draw the text outside the slices. Is it using the line dataSet.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE) ?? I didn't see setYValuePosition() method in mpandroidchart library.Is this because am using an older library?? Currently i am using mpandroidchartlibrary-2-2-4.jar for building piechart.
How to show the data with a line outside piechart using MPchart
com.github.PhilJay:MPAndroidChart:v2.0.9 , can anyone help me with this

I need the values to be outside the pie chart with a line .
@gokulrajkc Use the below code
`
pieEntryList = new ArrayList
PieData data = new PieData(dataSet);
data.setDrawValues(false);
pchart.setData(data);
pchart.setEntryLabelColor(Color.BLACK);
pchart.setEntryLabelTextSize(7f);
pchart.setEntryLabelTypeface(tf);
// undo all highlights
pchart.highlightValues(null);
// refresh/update pie chart
pchartRepOne.invalidate();`
Where
dataSet.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
dataSet.setValueLinePart1OffsetPercentage(80.f);
dataSet.setValueLinePart1Length(0.2f);
dataSet.setValueLinePart2Length(0.4f);
solves your problem.You can change the line size by using the above codes. This code suits for the latest mpandroidchart library.
com.github.PhilJay:MPAndroidChart:v3.0.1
I think there is no provision for the same in com.github.PhilJay:MPAndroidChart:v2.0.9.Use the latest library, its far better than the older libraries.
How to remove the bright whiter translucent circle in the pie chart?
I am just trying to set text near line but unable to add. Please tell any one how to set label near line in Pie Chart.
mChart.setOnChartValueSelectedListener(this);
// mChart.setTouchEnabled(false);
mChart.setUsePercentValues(true);
mChart.getDescription().setEnabled(false);
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
mChart.setDrawHoleEnabled(true);
mChart.setHoleColor(Color.WHITE);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(80f);
mChart.setTransparentCircleRadius(61f);
mChart.setRotationAngle(0);
// enable rotation of the chart by touch
mChart.setRotationEnabled(true);
mChart.setHighlightPerTapEnabled(true);
float mult = range;
ArrayList
ArrayList<Integer> colors = new ArrayList<Integer>();
for (int i = 0; i < globalViewDetailsDataArrayList.size(); i++) {
colors.add(Color.parseColor(globalViewDetailsDataArrayList.get(i).getColor()));//red
}
dataSet.setColors(colors);
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(11f);
data.setValueTextColor(Color.BLACK);
dataSet.setDrawValues(false);
mChart.setData(data);
mChart.setEntryLabelColor(Color.BLACK);
mChart.setEntryLabelTextSize(7f);
mChart.highlightValues(null);
mChart.invalidate();
mChart.spin(20000, 0, 360, Easing.EasingOption.EaseInOutBounce); // mChart.animateY(14000, Easing.EasingOption.EaseInOutQuad); Legend l = mChart.getLegend(); l.setEnabled(true); l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT); l.setOrientation(Legend.LegendOrientation.VERTICAL); l.setDrawInside(true); l.setXEntrySpace(7f); l.setYEntrySpace(0f); l.setYOffset(0f); mChart.setEntryLabelColor(Color.WHITE); mChart.setEntryLabelTextSize(12f);
This still appears to be broke on 3.0.0-beta1
Also once moving to outside slice value text color only shows white.
![]()
data.setValueTextColor(Color.BLACK); dataSet.setValueLinePart1OffsetPercentage(90.f); dataSet.setValueLinePart1Length(1f); dataSet.setValueLinePart2Length(.2f); dataSet.setValueTextColor(Color.BLACK); dataSet.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
I faced the same issue and this line of code fixed it for me
pieChart.setEntryLabelColor(Color.YELLOW);
How to remove the line when we position of label in outside slice ?
use match parent in pie chart that's all