2

我正在尝试使用 GraphView 绘制一个简单的图形,但出现编译错误:“找不到符号类 GraphViewSeries”。我还尝试添加“import com.jjoe64.graphview.GraphViewSeries;” 但得到同样的错误。请帮助解决此错误。

build.gradle 文件:

dependencies {        
compile fileTree(dir: 'libs', include: ['*.jar'])        
testCompile 'junit:junit:4.12'        
compile 'com.android.support:appcompat-v7:23.1.1'        
compile 'com.android.support:design:23.1.1'        
compile 'com.google.android.gms:play-services-gcm:8.4.0'        
compile 'com.android.support:support-v4:23.1.1'        
compile 'com.jjoe64:graphview:4.0.1'    
}

代码:

import android.graphics.Color;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.LinearLayout;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.GridLabelRenderer;
import com.jjoe64.graphview.Viewport;
import com.jjoe64.graphview.series.DataPoint;
import com.jjoe64.graphview.series.LineGraphSeries;
import java.util.Random;

public class ResultGraph extends AppCompatActivity {
private final Handler mHandler = new Handler();
private Runnable mTimer1;
private Runnable mTimer2;
private GraphView graphView;
private GraphViewSeries exampleSeries1;
private GraphViewSeries exampleSeries2;
private double graph2LastXValue = 5d;
private GraphViewSeries exampleSeries3;

//change graphType to line if bar chart not required
private String graphType = "bar";

private double getRandom() {
    double high = 3;
    double low = 0.5;
    return Math.random() * (high - low) + low;
}


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_student_result_graph);

    //example series data
    exampleSeries1 = new GraphViewSeries(new GraphViewData[] {
            new GraphViewData(1, 2.0d)
            , new GraphViewData(2, 1.5d)
            , new GraphViewData(2.5, 3.0d)
            , new GraphViewData(3, 2.5d)
            , new GraphViewData(4, 1.0d)
            , new GraphViewData(5, 3.0d)
    });
    exampleSeries3 = new GraphViewSeries(new GraphViewData[] {});
    exampleSeries3.getStyle().color = Color.CYAN;
}

}

4

0 回答 0