我正在使用 MPAndroidChartLibrary 并在显示图例时遇到问题

I m using MPAndroidChartLibrary and facing issue when showing legend

我正在使用 MPANdroidChartLibrary,但在图表底部显示垂直图例时遇到问题。最后的图例被砍掉了。

见附图:

由于最后一个图例在小型设备中进行了 AM 注册后被删除。 我关注

: and 关于堆栈溢出的帖子,但对我没有任何作用。

令人惊讶的是,即使在图表周围使用滚动视图后,此问题也只会出现在较小的设备上,而在 6 英寸以上的大型设备上,所有图例都可以正常显示。

  1. 随着图例的增长添加尽可能多的偏移量。

    有两种方法可以在图表的顶部和底部添加指定的填充

    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. 通过这行代码,您可以设置下一行和图例最后一个条目之间的边距!

    legend.setYOffset(50f);
    

    随着图例的增加,您可以增加值,并且在减少图例条目时,您也可以降低该值!

    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