Search code examples
javaandroidgraphandroid-graphview

Maximal values of axes in a GraphView


I have the following code:

LineGraphSeries<DataPoint> series = new LineGraphSeries<>(arr);
                graphView.addSeries(series);
                graphView.getViewport().setMaxX(31);
                graphView.getViewport().setMaxY(150);
                graphView.getViewport().setMinX(1);
                graphView.getViewport().setMinY(0);

I need to set maximal and minimal values of axises by this code, but when I run the program I have this values:

enter image description here

What's the matter?


Solution

  • From javadoc:

    Make sure to set the y bounds to manual via setYAxisBoundsManual(boolean)

    So you must also add

    graphView.getViewport().setYAxisBoundsManual(true);
    graphView.getViewport().setXAxisBoundsManual(true);