GraphView水平轴标签padding
GraphView horizontal axis labels padding
我正在使用 GraphView 库在我的 android 应用程序上创建图形,但我的水平 (X) 轴标签有问题。
如您所见,here 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(true);
您正在尝试添加 1 个屏幕可以处理的数字。
我遇到了同样的问题,我所做的是将水平角度 属性 设置为 90 度,它以垂直方式显示标签。
但我最终将它设置为 135 度,因为它提供了更好的结果,如:
graph.getGridLabelRenderer().setHorizontalLabelsAngle(135);
我正在使用 GraphView 库在我的 android 应用程序上创建图形,但我的水平 (X) 轴标签有问题。 如您所见,here 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(true);
您正在尝试添加 1 个屏幕可以处理的数字。
我遇到了同样的问题,我所做的是将水平角度 属性 设置为 90 度,它以垂直方式显示标签。
但我最终将它设置为 135 度,因为它提供了更好的结果,如:
graph.getGridLabelRenderer().setHorizontalLabelsAngle(135);