Display all values on X-axis android studio

735 Views Asked by At

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. enter image description here

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.

enter image description here

Is there any other way to display it so all the x-axis values are visible, with it overlapping.

2

There are 2 best solutions below

6
Francesco Bocci On BEST ANSWER

You can show vertical (or at least at an angle) using .setHorizontalLabelsAngle(90);

0
AudioBubble On

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