MPAndroidChart - Legend labels are being cut off

后端 未结 9 1348
自闭症患者
自闭症患者 2020-12-15 17:18

I am using MPAndroidChart library. Anybody has this problem? When I put the labels in BOTTOM position, these are cut.

Thank you

相关标签:
9条回答
  • 2020-12-15 18:09

    They are cut because your text is too long and the library does not support "wrapping" of the labels to a new line.

    You will either have to shorten your legend labels or implement the desired functionality yourself.

    UPDATE:

    Word wrapping for the Legend is now supported.

    chart.getLegend().setWordWrapEnabled(true);
    
    0 讨论(0)
  • 2020-12-15 18:10

    Here I will show you an easy way by "Traditional Android Way", it's quite simple, my code is below:

    <LinearLayout
        android:id="@+id/i_am_chart_view_container"
        ...
        android:paddingRight="20dp"
        android:clipChildren="false"
        android:clipToPadding="false"
        .../>
    

    Just need to add some padding to the container layout, or some margin to the chart view, and finally set clipChildren&clipToPadding to false.

    Result below:

    the blue area is padding or margin area.

    enter image description here

    0 讨论(0)
  • 2020-12-15 18:10

    After a long research, I found the solution. The below code solved it.

    chart.getLegend().setWordWrapEnabled(true);

    0 讨论(0)
提交回复
热议问题