Yotam Dahan
Yotam Dahan

Reputation: 699

GraphView horizontal axis labels padding

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?

Upvotes: 1

Views: 1569

Answers (2)

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

Upvotes: 1

user7875739
user7875739

Reputation:

Try to add

graph.getViewport().setScrollable(true);

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

Upvotes: 0

Related Questions