当前位置: 代码迷 >> Android >> GraphView水平轴标签填充
  详细解决方案

GraphView水平轴标签填充

热度:46   发布时间:2023-08-04 10:29:15.0

我正在使用GraphView库在我的Android应用程序上创建图形,我的水平(X)轴标签出现问题。 正如你看到的那样, X轴上的数字标签存在问题,数字相互徘徊,我愿意使用填充来避免这种情况。

虽然经过长时间的在线研究,我还没有找到任何答案。

这是我的图形设计代码:

    GraphView graph = (GraphView) findViewById(R.id.graph);
    LineGraphSeries<DataPoint> series = new LineGraphSeries<>(getDataPoint());
    GridLabelRenderer gridLabel = graph.getGridLabelRenderer();
    gridLabel.setHumanRounding(true);
    gridLabel.setNumHorizontalLabels(this.numberAxis);
    gridLabel.setHorizontalAxisTitle(getApplicationContext().getString(R.string.updates));
    gridLabel.setLabelHorizontalHeight(50);
    gridLabel.setVerticalAxisTitle(getApplicationContext().getString(R.string.weight));
    graph.addSeries(series);

如何避免水平轴标签相互悬停?

尝试添加

。graph.getViewport()setScrollable(真);

您正在尝试添加1个屏幕可以处理的大量数字。

我遇到了同样的问题,我所做的是将水平角度属性设置为90度,并以垂直方式显示标签。

但我最终把它设置为135度,因为它给出了更好的结果,如:

graph.getGridLabelRenderer().setHorizontalLabelsAngle(135);

  相关解决方案