I solved this issue.
In my case
.DataPointInterface.getX()
Is happening when you set your minimum range of x from 1
and your DataPoint Array length is smaller than 1.
example
// list.size() return null
// for example, no data from Sqlite is assigned to the list
// cus query return nothing.
DataPoint [] statsArray = new DataPoint[list.size()];
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(statsArray);
// set manual X bounds
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setMinX(1.0); //when 0 it work, just show nothing.
// when statsArray is null and you try setMinX(1.0) you get this error.
graph.getViewport().setMaxX(list.size());
So my SOLUTION to this problem is:
List<Integer> list = DatabaseObject.someQuery("SOME EXAMPLE QUERY");
DataPoint [] statsArray;
if(list.size() > 0) {
// Code for list longer than 0, query return something
statsArray = new DataPoint[list.size()]; // so this is not null now
for (int i = 0; i < statsArray.length; i++) {
statsArray[i] = new DataPoint(i+1, list.get(i));
// i+1 to start from x = 1
}
}else{
// Query return nothing, so we add some fake point
// IT WON'T BE VISIBLE cus we starts graph from 1
statsArray = new DataPoint[] {new DataPoint(0, 0)};
}
GraphView graph = (GraphView) findViewById(R.id.graph);
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(statsArray);
// set manual X bounds
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setMinX(1.0);
graph.getViewport().setMaxX(list.size());
So now our code won't make.
NullPointerException when setting axis bounds on GraphView
It's like, when you create graph from 0, null is "ok".
When you create graph from 1, null is not ok.
I know it's not best solution, but it might help somebody.