Search code examples
android-graphview

How to change X and Y axis numbers' colour in GraphView for Android?


I'm using GraphView in my app to display a realtime graph from the magnetic field sensor values.

Initialized the GraphView object as follows:

GraphView graph = findViewById(R.id.graph);
...

and set data series and grid colour using the following:

...
graph.addSeries(series);
...
graph.getGridLabelRenderer().setGridColor(Color.RED);

And I get this as a result.

Graph with numbers I want to change highlited

Now I want to remove the X and Y axis value numbers indicated in the above picture by green arrows, how can I do that? If they can't be removed, how can I change their font colour? I'll make it match the background.


Solution

  • Just found what I was looking for, to disable the X and Y numbers along the axes, use:

    graph.getGridLabelRenderer().setVerticalLabelsVisible(false);
    graph.getGridLabelRenderer().setHorizontalLabelsVisible(false);