jjoe64 / GraphView

Android Graph Library for creating zoomable and scrollable line and bar graphs.
https://github.com/jjoe64/GraphView/wiki
Other
2.75k stars 811 forks source link

java.lang.NullPointerException: Attempt to invoke interface method 'double com.jjoe64.graphview.series.DataPointInterface.getX()' on a null object reference #396

Closed Mateusz1992 closed 8 years ago

Mateusz1992 commented 8 years ago

As in the topic, do you know what can be the reason of the NullPointerException ?

Sample of code:

`if (ileRazyX < ((int) (MAX_X / STEP) + 1)) {

                                                        valuesX[ileRazyX] = new DataPoint(graph2LastXValueX, mrs.get(i).getX() * 9.81);
                                                        SeriesXAccel.appendData(valuesX[ileRazyX], AutoScrollX, ((int) (MAX_X / STEP) + 1));

                                                        if (graph2LastXValueX >= Xview && Lock == true) {
                                                            SeriesXAccel.resetData(new DataPoint[]{});
                                                            graph2LastXValueX = 0;
                                                        } else graph2LastXValueX += STEP;

                                                        if (Lock == true) {
                                                            graphView.getViewport().setMinX(0);
                                                            graphView.getViewport().setMaxX(Xview);
                                                        } /*else {
                                                            graphView.getViewport().setMinX(graph2LastXValueX - Xview);
                                                            graphView.getViewport().setMaxX(Xview);
                                                        }*/

                                                        ileRazyX++;

                                                    } else {
                                                        ileRazyX = 0;

                                                                /*GraphView.removeView(graphView);
                                                                GraphView.addView(graphView);*/
                                                    }`

Every help is highly appreciated. Thanks in advance.

jjoe64 commented 8 years ago

i think it's already fixed or an issue on your implementation side