MPAndroidChart无法正常显示

时间:2015-05-04 22:57:55

标签: android charts mpandroidchart

我正在Android应用中实现MPAndroidChart,但它显示在图片中:

enter image description here

基本上我正在复制tutorial中的图表代码。

我在我的代码中这样做:

BarChart mChart;
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_mi_history, container, false);

     mChart = (BarChart) view.findViewById(R.id.chart);
    ArrayList<BarEntry> entries = new ArrayList<>();
    entries.add(new BarEntry(4f, 0));
    entries.add(new BarEntry(8f, 1));
    entries.add(new BarEntry(6f, 2));
    entries.add(new BarEntry(12f, 3));
    entries.add(new BarEntry(18f, 4));
    entries.add(new BarEntry(9f, 5));
    BarDataSet dataset = new BarDataSet(entries, "# of Calls");

    ArrayList<String> labels = new ArrayList<String>();
    labels.add("January");
    labels.add("February");
    labels.add("March");
    labels.add("April");
    labels.add("May");
    labels.add("June");
    BarData data = new BarData(labels, dataset);
    mChart.setData(data);

    mChart.setDescription("# of times Alice called Bob");
    return view;
}

我做错了什么?

0 个答案:

没有答案