Вопрос

I am using some android library which is in the link .. https://github.com/jjoe64/GraphView-Demos .. I tried with the realtime graph example , https://github.com/jjoe64/GraphView-Demos/blob/master/src/com/jjoe64/graphviewdemos/RealtimeGraph.java ... It works well for me but I have few problem x-y axis scale settings . When ever new data is load during re-drwaing the graph , all x-y axis scale value changes as per the in put data values .

I want to fix the y axis from the range 1 to 6 and x from 1 to 30 .. each with a increment scale of 1 .. This axis label values should be always fixed and the graph should change as per the in put data .. I need some way to the fixed labes.

Это было полезно?

Решение

did you try with manual y axis? E.g.

graphView.setManualYAxisBounds(100, -100) 

Другие советы

You can use setMinX and setMinY functions like this code below, this code will draw + graph with X-Y axis if you didn't put some data in it:

graph.getViewport().setYAxisBoundsManual(true);
graph.getViewport().setMinY(-1);   //define your limits on here or use zoom code below!
graph.getViewport().setMaxY(1);

graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setMinX(-1);
graph.getViewport().setMaxX(1);

Bonus: If you want to zoom in/out with your fingers, use this code below:

graph.getViewport().setScalable(true);
graph.getViewport().setScalableY(true);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top