英文:
How to set data of MPAndroidChart LineChart with an ArrayList of Ints?
问题
我有一个整数ArrayList,我想在我的MPAndroidChart LineChart中使用它。然而,我对Java还很陌生,不知道如何将其转换为所需的"Entry"数据类型。你能帮助我吗?
我尝试了以下方法:
ArrayList<int[]> data2line = new ArrayList<>(Arrays.asList(data));
LineDataSet lineDataSet1 = new LineDataSet(data2line, "数据集1");
ArrayList<ILineDataSet> dataSets = new ArrayList<>();
dataSets.add(lineDataSet1);
LineData dataLine = new LineData(dataSets);
lineChart.setData(dataLine);
英文:
I have an ArrayList of ints that I would like to use in my MPAndroidChart LineChart. However, I am new to Java and don't know how to convert it to the required "Entry" data type. Can you help me?
I tried the following:
ArrayList<int[]> data2line= new ArrayList<>(Arrays.asList(data));
LineDataSet lineDataSet1 = new LineDataSet(data2line,"Data Set 1");
ArrayList<ILineDataSet> dataSets = new ArrayList<>();
dataSets.add(lineDataSet1);
LineData dataLine = new LineData(dataSets);
lineChart.setData(dataLine);
答案1
得分: 0
ArrayList
entries.add(new Entry(1, 50));
entries.add(new Entry(2, 100));
英文:
You need an array of entries, something like this:
ArrayList<Entry> entries = new ArrayList<>();
entries.add(new Entry(1, 50));
entries.add(new Entry(2, 100));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论