【问题标题】:MPAndroidChart - Remove top border / axis since v2MPAndroidChart - 自 v2 以来删除顶部边框/轴
【发布时间】:2015-05-11 10:08:04
【问题描述】:

我将 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 上有值,但没有水平轴线/边界。我找不到任何隐藏它的命令。

【问题讨论】:

    标签: android mpandroidchart


    【解决方案1】:

    您是否尝试在YAxis 上拨打setDrawAxisLine(...)setDrawGridLines(...)

    这里是full axis documentation

    这里是documentation for YAxis only

    【讨论】:

    • 感谢您的帮助。是的,我试过了,尽管它不太可能解决我的问题,因为问题是水平轴,而不是垂直轴。我添加了我的完整代码和屏幕截图,希望有更多的想法:)
    • 试试yAxis.setDrawGridLines(...)。这一切都在文档中。
    • 我理解您对文档的看法。我在这里发帖的重点是连续两天阅读文档,但仍然没有找到这是(XAxis,YAxis,外边框)的一部分,也没有找到如何隐藏它。 yl.setDrawGridLines(false) 工作,您可以编辑您的主要答案以便我接受吗?
    【解决方案2】:

    删除你想要的任何行:)

    ...       
            //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);
    

    【讨论】:

    • 完美,谢谢!
    【解决方案3】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多