Android MPAndroidChart Text Overlapping with PieChart Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Android MPAndroidChart Text Overlapping with PieChart without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I am using MPAndroidChart for showing values in PieChart.

I Refered this but still am not clear to fix text overlapping in PieChart Below image am getting as result.

The orange value contains 3, it showing at bottom, but green value contains 2, it not showing up properly. Solution needs for green value.

enter image description here

    chart.setUsePercentValues(false);
    chart.getDescription().setEnabled(false);
    chart.getDescription().setTextSize(25f);
    chart.setExtraOffsets(5, 5, 5, 5);
    chart.getLegend().setEnabled(false);

    chart.setDragDecelerationFrictionCoef(0.95f);

    chart.setCenterTextTypeface(tfLight);
    chart.setCenterTextColor(getResources().getColor(R.color.white));

    chart.setDrawHoleEnabled(true);
    chart.setHoleColor(getResources().getColor(R.color.toolBar));

    chart.setTransparentCircleColor(R.color.toolBar);
    chart.setTransparentCircleAlpha(110);

    chart.setHoleRadius(35f);
    //  chart.setTransparentCircleRadius(61f);
    chart.getXAxis().setTextColor(Color.WHITE);
    chart.setDrawCenterText(true);

    chart.setRotationAngle(0);
    // enable rotation of the chart by touch
    chart.setRotationEnabled(false);
    chart.setHighlightPerTapEnabled(true);

Can Anyone help me out from this issue, where my code went wrong?

Thanks in Advance.

Answer

Finally i got solution by adding below lines to avoid overlapping text with pieChart,

PieData data = new PieData(dataSet);
dataSet.setValueLinePart1OffsetPercentage(90.f); 
dataSet.setValueLinePart1Length(.10f);
dataSet.setValueLinePart2Length(.50f);

Getting result like below,

enter image description here

We are here to answer your question about Android MPAndroidChart Text Overlapping with PieChart - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji