英文:
Display all values on X-axis android studio
问题
我在我的应用程序中使用GraphView实现了一个折线图,允许用户每天输入数据并按日期记录,但我遇到了一个问题,无法在x轴上显示所有的值。
我使用了以下代码来分隔块 weightGraph.getGridLabelRenderer().setNumHorizontalLabels(5);
然后效果如下图所示,值彼此重叠在一起。
如果我将这段代码中的值从5更改为3,即 weightGraph.getGridLabelRenderer().setNumHorizontalLabels(3);
,那么它就不会像下图那样显示所有的值。
是否有其他方法可以将所有x轴的值都显示出来,而不重叠呢?
英文:
I have implemented a line graph using graphview in my app that allows the user to input data daily and records it by the date, but I am having an issue to display all the values on the x-axis.
I used this line of to separate the blocks weightGraph.getGridLabelRenderer().setNumHorizontalLabels(5);
and then looks like the image below where the values are overlapping each other.
and if I change the value of 5 to 3 in this codeweightGraph.getGridLabelRenderer().setNumHorizontalLabels(3);
then it does not display all the values like the picture below.
Is there any other way to display it so all the x-axis values are visible, with it overlapping.
答案1
得分: 0
你可以使用.setHorizontalLabelsAngle(90);
来显示垂直方向(或至少倾斜角度)。
英文:
You can show vertical (or at least at an angle) using .setHorizontalLabelsAngle(90);
答案2
得分: 0
我已经决定删除这行代码 weightGraph.getGridLabelRenderer().setNumHorizontalLabels(10);
,这使得图表可以每天按需增长,但我添加了这行代码,以便 x 值不会彼此重叠。weightGraph.getGridLabelRenderer().setHorizontalLabelsAngle(45);
。
英文:
I have decided to remove this line of code weightGraph.getGridLabelRenderer().setNumHorizontalLabels(10);
Which enables the graph to increase as it wants daily but I did add this line of code so the x values do not overlap each other. weightGraph.getGridLabelRenderer().setHorizontalLabelsAngle(45);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论