How to make graphview in android stay still when i add series to it?

28 Views Asked by At

Creating graph:

GraphView graph = (GraphView) (findViewById(R.id.graph));
        graph.getGridLabelRenderer().setHorizontalLabelsColor(Color.rgb(0, 68, 173));
        graph.getGridLabelRenderer().setVerticalLabelsColor(Color.rgb(0, 68, 173));
        GridLabelRenderer glr = graph.getGridLabelRenderer();
        glr.setPadding(32);
        glr.setHorizontalAxisTitle("HORIZONTAL");
        glr.setHorizontalAxisTitleTextSize(25);
        glr.setHorizontalAxisTitleColor(Color.rgb(0, 68, 173));
        glr.setVerticalAxisTitle("VERTICAL");
        glr.setVerticalAxisTitleTextSize(25);
        glr.setVerticalAxisTitleColor(Color.rgb(0, 68, 173));
        graph.getViewport().setScalable(true);

Adding data:

GraphView graph = (GraphView) (findViewById(R.id.graph));
                        graph.getViewport().setXAxisBoundsManual(true);
                        graph.getViewport().setMaxX(array_for_indication_for_graph.size());
                        graph.getViewport().setMinX(0);
                        graph.getViewport().setYAxisBoundsManual(true);
                        graph.getViewport().setMaxY(max + 1);
                        graph.getViewport().setMinY(min - 1);

                        LineGraphSeries<DataPoint> series = new LineGraphSeries<>();
                        series.setColor(Color.rgb(255, 125, 0));
                        for (int i = 0; i < array_for_indication_for_graph.size(); i++) {
                            series.appendData(new DataPoint(i, Float.parseFloat(array_for_indication_for_graph.get(i))), true, 20000);
                        }
                        graph.addSeries(series);
                        graph_was_drawn = 1;

I tried delete padding, set scrolltoEnd false, but nothing works...

Photos:Correct work before measurment

Photos:Wrong work

0

There are 0 best solutions below