无法使用PhilJay / MPAndroidChart库为Android运行图形

时间:2016-07-28 06:26:10

标签: android mpandroidchart

allprojects {
repositories {
    jcenter()
    maven { url "https://jitpack.io" }
}

}

compile' com.github.PhilJay:MPAndroidChart:v2.2.4'

public class MainActivity extends AppCompatActivity {

BarChart chart;
ArrayList<BarEntry> entries;
ArrayList<String> labels;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    chart = (BarChart) findViewById(R.id.barChartId);

    entries = new ArrayList<>();

    labels = new ArrayList<>();

    entries.add(new BarEntry(2f, 0));
    entries.add(new BarEntry(4f, 1));
    entries.add(new BarEntry(6f, 2));
    entries.add(new BarEntry(8f, 3));
    entries.add(new BarEntry(7f, 4));
    entries.add(new BarEntry(3f, 5));

    labels.add("January");
    labels.add("February");
    labels.add("March");
    labels.add("April");
    labels.add("May");
    labels.add("June");

    BarDataSet barDataSet = new BarDataSet(entries, "Projects");

    BarData barData = new BarData(labels, barDataSet);

    barDataSet.setColors(ColorTemplate.COLORFUL_COLORS);

    chart.setData(barData);

    chart.animateY(3000);

}

错误: java.lang.NoSuchMethodError:类Lcom / github / mikephil / charting / data / BarEntry中没有直接方法(FI)V;

0 个答案:

没有答案