如何在 MPAndroidChart 中获取 y 轴标签的宽度

How to get the width of y-axis label in MPAndroidChart

如何获取左侧y轴标签的宽度?或图表开始和 y 轴之间的 space

如果你想获得最长的标签宽度,那么你可以这样做:

chart.getRendererLeftYAxis()
     .getPaintAxisLabels()
     .measureText(chart.getAxisLeft().getLongestLabel())

或者您可以获得标签两侧的边距:

chart.getAxisLeft().getXOffset()

或者你可以获取坐标轴宽度(最后两个值的总和):

chart.getAxisLeft().getRequiredWidthSpace(
    chart.getRendererLeftYAxis().getPaintAxisLabels())