Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android MPAndroidChart Text Overlapping with PieChart

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.

like image 292
Android Avatar asked Apr 14 '26 10:04

Android


1 Answers

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

like image 88
Android Avatar answered Apr 17 '26 03:04

Android



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!