Search code examples
javaandroidandroid-graphview

Add space between graph and tick labels in GraphView?


I am trying out the GraphView Library for creating charts on Android. It looks quite decent, but I am wondering if there is a way to add some space between the tick labels and the graph itself. As you can see, there is basically none:

enter image description here

I use the following code to set up the graph (very similar to the example):

GraphView graph = (GraphView)view.findViewById(R.id.graph);
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[] {
    new DataPoint(0, 1),
    new DataPoint(1, 5),
    new DataPoint(2, 3)
});
graph.addSeries(series);

I tried using graph.getGridLabelRenderer().setPadding(), but that just added padding around the whole graph.

So, is there a way to put some padding around those labels?


Solution

  • yes it is possible in the current version in github (will be released in 4.0.1). There is the method:

    graph.getGridLabelRenderer().setLabelsSpace(x)