I have a line graph that I add data to each time the user enters a number. The user enters a number 50 times, so I want the x axis to range from 1 to 50 in increments of 1. On the y axis, I want it to range from 2 - 15 (user enters a number between 2 and 15) in increments of 1. I'm really not sure how to do this, this is what I have:
graph = (GraphView) findViewById(R.id.session_graph);
series = new LineGraphSeries<DataPoint>(new DataPoint[] {});
graph.addSeries(series);
graph.getViewport().setMinX(1);
graph.getViewport().setMaxX(50);
graph.getViewport().setMinY(2.0);
graph.getViewport().setMaxY(15.0);
However, when I fire up my app, the x and y axis range from 0 - 2 in intervals of 0.5
GraphView sets the axis range by default. What you wish to do is set the limits manually. After setting the ranges, you must tell the graphView to set the range as per your directive. This is how:
graph = (GraphView) findViewById(R.id.session_graph);
series = new LineGraphSeries<DataPoint>(new DataPoint[] {});
graph.addSeries(series);
graph.getViewport().setMinX(1);
graph.getViewport().setMaxX(50);
graph.getViewport().setMinY(2.0);
graph.getViewport().setMaxY(15.0);
graph.getViewport().setYAxisBoundsManual(true);
graph.getViewport().setXAxisBoundsManual(true);
Hope this helps and the answer is not too late :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With