MPAndroidChart - 从 v2 开始删除顶部边框/轴

MPAndroidChart - Remove top border / axis since v2

我将 MPAndroidChart 从 v1.7 升级到 v2,并且不得不更改一些东西。 新事物之一是我现在似乎有最大值的顶部边框。

我试图隐藏所有边框的代码是这样的:

    LineChart graph = (LineChart) connectionView.findViewById(R.id.graph);
    graph.setDrawGridBackground(false);
    graph.setDrawBorders(false);
    graph.setDescription("");

    YAxis yr = graph.getAxisRight();
    yr.setEnabled(false);
    yr.setDrawAxisLine(false);

    YAxis yl = graph.getAxisLeft();
    yl.setValueFormatter(formatierer);
    yl.setShowOnlyMinMax(true);
    yl.setDrawAxisLine(false);

    XAxis xl = graph.getXAxis();
    xl.setPosition(XAxis.XAxisPosition.BOTTOM);
    xl.setDrawGridLines(false);
    xl.setDrawAxisLine(false);

    yl.setAxisMaxValue((float) graphpoint_max);

仍然 - 我有一行显示最大值。我想在 YAxis 上有值,但没有水平轴线/边框。我找不到任何隐藏它的命令。

您试过在 YAxis 上呼叫 setDrawAxisLine(...)setDrawGridLines(...) 吗?

这里是 full axis documentation.

这里是 documentation for YAxis only

顶线作为 X 轴的一部分绘制。你需要调用它来摆脱它:chart.getXAxis().setDrawAxisLine(false);.

删除你想要的任何行:)

...       
        //remove top border
        chart.getXAxis().setDrawAxisLine(false);
        
        //remove left border
        chart.getAxisLeft().setDrawAxisLine(false);
        
        //remove right border
        chart.getAxisRight().setDrawAxisLine(false);

     

如果您想删除所有网格、线条和标签

chart.getDescription().setEnabled(false);
chart.setDrawGridBackground(false);

chart.setHighlightFullBarEnabled(false);

chart.getXAxis().setDrawGridLines(false);
chart.getAxisLeft().setDrawGridLines(false);
chart.getAxisRight().setDrawGridLines(false);
chart.getAxisRight().setDrawLimitLinesBehindData(false);
chart.getAxisLeft().setDrawLabels(false);
chart.getAxisRight().setDrawLabels(false);
chart.getXAxis().setDrawLabels(false);
chart.getXAxis().setDrawLimitLinesBehindData(false);
chart.getLegend().setEnabled(false);