1

I'm using GraphView library to create graph on my android application and I having problem with my horizontal (X) axis labels. As you can see here there is problem with the numbers labels in the X axis, the numbers are hovering each other and I'm willing to use padding to avoid that.

Though after long researches online I have not found any answers.

Here is my graph design code:

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

How can I avoid hovering of the horizontal axis labels on each other?

Yotam Dahan
  • 689
  • 1
  • 9
  • 33
  • there is not enough space so you should decrease the number of horizontal labels via `setNumHorizontalLabels(5)` as example – appsthatmatter Feb 14 '17 at 14:07

2 Answers2

1

I had the same problem, what I did is I set the horizontal angle property to 90 degrees and it displays the labels in vertical.

But I finally set it to 135 degrees as it gives a better result, as:

graph.getGridLabelRenderer().setHorizontalLabelsAngle(135);

Reema Parakh
  • 1,347
  • 3
  • 19
  • 46
0

Try to add

graph.getViewport().setScrollable(true);

You are trying to add to much numbers that 1 screen can handle.