Graphical range of x and y

I have a line graph in which I add data every time a user enters a number. The user enters a number 50 times, so I want the x axis to be in the range from 1 to 50 in steps of 1. On the y axis, I want it to be in the range from 2 to 15 (the user entered a number from 2 to 15) in s Step 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 run my application, the x and y axes change from 0 to 2 at intervals of 0.5

+5
source share
1 answer

GraphView sets the default axis range. You want to set the limits manually. After setting ranges, you must specify a schedule to set the range according to your directive. Here's how to do it:

 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 :)

+11
source

Source: https://habr.com/ru/post/1236365/


All Articles