3

I m using MPANdroidChartLibrary, but facing issues when showing vertical legends in the bottom of the chart. The last legend cut off.

See attached image:enter image description here

As the last legend is cut after AM registration in small devices. I follow Answer1

3: MpAndroidChart Piechart legends cutting issue at the bottom center and Answer2 posts on stack overflow but nothing works for me.

Surprisingly, This issue only comes on smaller devices even after using scroll view around the chart while on large device like above 6 inch all legends are visible properly.

Ankur Chaudhary
  • 2,709
  • 3
  • 19
  • 30

1 Answers1

4
  1. Add as much offset as you legend grows.

    there are two methods add the specified padding at the top and bottom of the chart

    mPiecPieChart.setExtraBottomOffset(12f);//from bottom side if legends are bottom side 
    
    mPiecPieChart.setExtraTopOffset(12f);//if legends are on top side or change both if legend are on both sides
    
  2. by this line of code you can set margin between below line and legend last entry!

    legend.setYOffset(50f);
    

    as your legends increase you can increase value and on reducing legend entries you can reduce this value also!

    Legend legend = chart.getLegend();
    legend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    legend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    legend.setOrientation(Legend.LegendOrientation.VERTICAL);
    legend.setDrawInside(false);
    legend.setYOffset(50f);//here value changes 
    
Abdur Rehman
  • 1,247
  • 10
  • 13