本文介绍了jjoe64 GraphView库中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以帮助我吗?我发现此错误,但找不到解决我问题的方法.这是Android错误:
someone can help me? I found this error and I can't find the resolution to my problem. This is the Android Error:
09-15 18:26:47.434 3096-3096/com.example.user.navigationdrawer E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.user.navigationdrawer, PID: 3096
java.lang.IllegalArgumentException: new x-value must be greater then the last value. x-values has to be ordered in ASC.
at com.jjoe64.graphview.series.BaseSeries.appendData(BaseSeries.java:388)
at com.example.user.navigationdrawer.SeventhFragment$1.onDataChange(SeventhFragment.java:75)
at com.firebase.client.Query$1.onDataChange(Query.java:158)
at com.firebase.client.core.ValueEventRegistration.fireEvent(ValueEventRegistration.java:45)
at com.firebase.client.core.view.DataEvent.fire(DataEvent.java:45)
at com.firebase.client.core.view.EventRaiser$1.run(EventRaiser.java:38)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
这是我的代码:
package com.example.user.navigationdrawer;
import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.firebase.client.DataSnapshot;
import com.firebase.client.Firebase;
import com.firebase.client.FirebaseError;
import com.firebase.client.ValueEventListener;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.series.BarGraphSeries;
import com.jjoe64.graphview.series.DataPoint;
import com.jjoe64.graphview.series.LineGraphSeries;
import com.jjoe64.graphview.series.Series;
public class SeventhFragment extends Fragment{
GraphView graphView;
FirebaseAuth auth;
FirebaseUser user;
Firebase mRef;
LineGraphSeries<DataPoint> series;
View myView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
myView = inflater.inflate(R.layout.seventh_layout, container, false);
graphView = (GraphView) myView.findViewById(R.id.graph);
auth = FirebaseAuth.getInstance();
user = auth.getCurrentUser();
if (user == null){
Activity activity = getActivity();
Toast.makeText(activity, "Per accedere a questa funzione devi aver effettuato il login.", Toast.LENGTH_SHORT).show();
startActivity(new Intent(activity, LoginActivity.class));
}
graphView.getViewport().setXAxisBoundsManual(true);
graphView.getViewport().setMinX(0.0);
graphView.getViewport().setMaxX(24);
// set manual Y bounds
graphView.getViewport().setYAxisBoundsManual(true);
graphView.getViewport().setMinY(0.0);
graphView.getViewport().setMaxY(2000);
graphView.getViewport().setScrollable(true);
series = new LineGraphSeries<DataPoint>();
mRef = new Firebase("my url" );
mRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
final double Valore = dataSnapshot.getValue(double.class);
series.appendData(new DataPoint(1, Valore), false, 24); //what number must i write here?
}@Override
public void onCancelled(FirebaseError firebaseError) {
}});
mRef = new Firebase("my url" );
mRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
final double Valore = dataSnapshot.getValue(double.class);
series.appendData(new DataPoint(2, Valore), false, 25); //what number must i write here?
}@Override
public void onCancelled(FirebaseError firebaseError) {
}});
graphView.addSeries(series);
return myView;
}}
我想在图形中设置从FireBase检索的数据,但这给我一个错误.我正在使用库:com.jjoe64:graphview:4.1.0'帮助!
I want to set in the graph the data i recived from FireBase but it gives me an error. I'm using the library: com.jjoe64:graphview:4.1.0'HELP!
推荐答案
ADD jar文件作为库.这表明您没有在项目中添加GraphView库.
ADD jar file as a library .It is indicating that you did not add GraphView Library in your project .
这篇关于jjoe64 GraphView库中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!