GraphView - setXAxixBoundsManual and fragment

I'm having a problem with GraphView. In order to centre the graph on the x-axis, I take the lowest or highest integers from the array and the set the viewport like this: graph.getViewport().setMinY(highest value); // or graph.getViewport().setMinY(+lowest value);
graph.getViewport().setMaxY(-highest value); // or graph.getViewport().setMinY(lowest value);
graph.getViewport().setYAxisBoundsManual(true);

graph.getViewport().setMinX(0);
graph.getViewport().setMaxX(766);
graph.getViewport().setXAxisBoundsManual(true);

This works perfectly when I navigate to the fragment which contains the GraphView. However, when I navigate to the next fragment and then return, the app crashes. When I remove the setX/YAxisBoundsManual(true) lines, the app continues to work, but the graph is drawn anywhere but the on the X-Axis...above or below. The code used to draw the graph is slightly different on return as there is no need to recalculate the graph points. Instead, they are read from a bundle which was passed forward and back to the fragment.

Does anyone have any idea how to overcome this problem...or is there another way to centre the graph? The graph is a representation of audio data.

Here's my code:

public class ReviewBackFragment extends Fragment {

GraphView graph;
ComputeTask t = new ComputeTask();

//the ComputeTask is run when the fragment is first navigated to.

private class ComputeTask extends AsyncTask<Void, Void, ArrayList<Integer>> {

@Override
protected void onPreExecute() {
    // Runs on UI thread
 }
@Override
protected ArrayList<Integer> doInBackground(Void... params) {
}
@Override
protected void onPostExecute(ArrayList<Integer> res) {
    int lowest;
    int highest;
    int graphSpace = 0;
    int graphSpaceFit;

    if (lower.get(0) < 0) {
    lowest = lower.get(0) * -1;
} else {
    lowest = lower.get(0);
}
if (higher.get(0) < 0) {
    highest = higher.get(0) * -1;
} else {
    highest = higher.get(0);
}
if (lowest >= highest) {
    graphSpace = lowest;
} else if (highest >= lowest) {
    graphSpace = highest;
}

    graphSpaceFit = graphSpace + ((int) (Math.floor(graphSpace / 20)));

    LineGraphSeries<DataPoint> series = new LineGraphSeries<>(dataSmall());
       graph.getGridLabelRenderer().setGridStyle(GridLabelRenderer.GridStyle.NONE);
    graph.getGridLabelRenderer().setVerticalLabelsVisible(false);
    graph.getGridLabelRenderer().setLabelVerticalWidth(0);
    graph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
    graph.getGridLabelRenderer().setLabelHorizontalHeight(0);

    graph.getViewport().setYAxisBoundsManual(true);
    graph.getViewport().setMinY(graphSpaceFit);
    graph.getViewport().setMaxY(-graphSpaceFit);

    graph.getViewport().setXAxisBoundsManual(true);
    graph.getViewport().setMinX(0);
    graph.getViewport().setMaxX(766);

    series.setColor(Color.argb(255, 58, 148, 221));
    series.setThickness(1);
    graph.addSeries(series);

    horBundle.putInt("graphSpaceFit", graphSpaceFit);
    horBundle.putIntegerArrayList("graphPoints", graphPoints);}
    }
}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                     Bundle savedInstanceState) {
    View reviewBackView = inflater.inflate(R.layout.fragment_review_back, container, false);
graph = (GraphView) reviewBackView.findViewById(R.id.graph);
      graph.getGridLabelRenderer().setGridStyle(GridLabelRenderer.GridStyle.NONE);
graph.getGridLabelRenderer().setVerticalLabelsVisible(false);
graph.getGridLabelRenderer().setLabelVerticalWidth(0);
graph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
graph.getGridLabelRenderer().setLabelHorizontalHeight(0);
graph.getGridLabelRenderer().setPadding(wid / 8);

//the code below in if(reviewVar.getText() == "1"){} is run when the fragment is first navigated to.
if(reviewVar.getText() == "1"){
t.execute;
}

// the code below, within 'if(reviewVar.getText() == "2"){}' is run when the fragment is navigated back to...this is where the problem with setting the viewport bounds to manual occurs.
if(reviewVar.getText() == "2"){

Bundle pathBundle = this.getArguments();
String path = pathBundle.getString("pathString");
int folderBrowsed = pathBundle.getInt("folderBrowsed");
horBundle.putString("pathString", path);
horBundle.putInt("folderBrowsed", folderBrowsed);

if(pathBundle.getIntegerArrayList("graphPoints") != null){
    int graphSpaceFit = pathBundle.getInt("graphSpaceFit");
    graphPoints = pathBundle.getIntegerArrayList("graphPoints");
    horBundle.putInt("graphSpaceFit", graphSpaceFit);
    horBundle.putIntegerArrayList("graphPoints", graphPoints);

    DataPoint[] values = new DataPoint[766];
    for (int i = 0; i < 766; i++) {
        DataPoint v = new DataPoint(i, graphPoints.get(i * 20));
        values[i] = v;}

    LineGraphSeries<DataPoint> series = new LineGraphSeries<>(values);
    graph.getGridLabelRenderer().setGridStyle(GridLabelRenderer.GridStyle.NONE);
    graph.getGridLabelRenderer().setVerticalLabelsVisible(false);
    graph.getGridLabelRenderer().setLabelVerticalWidth(0);
    graph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
    graph.getGridLabelRenderer().setLabelHorizontalHeight(0);

    graph.getViewport().setMinY(graphSpaceFit);
    graph.getViewport().setMaxY(-graphSpaceFit);
    //graph.getViewport().setYAxisBoundsManual(true);

    graph.getViewport().setMinX(0);
    graph.getViewport().setMaxX(766);
    //graph.getViewport().setXAxisBoundsManual(true);

    series.setColor(Color.argb(255, 58, 148, 221));
    series.setThickness(1);
    graph.addSeries(series);
}
// Inflate the layout for this fragment
return reviewBackView;
    }
}