如果我不知道可能的条目数量,如何在DataPoint
添加要绘制的值?
DataPoint[] db = new DataPoint[]{
new DataPoint(5,4),
new DataPoint(2,4),
new DataPoint(4,4),
new DataPoint(9,0),
new DataPoint(0,3)} ;
PointsGraphSeries<DataPoint> series = new PointsGraphSeries<DataPoint>(db) ;
答案 0 :(得分:1)
在将DataPoint数组添加到LineGraphSeries之前调用此方法。
private void generateDataForGraph() {
int size = Amount.size();
values = new DataPoint[size];
for (int i=0; i<size; i++) {
Integer xi = Integer.parseInt(Dates.get(i));
Integer yi = Integer.parseInt(Amount.get(i));
DataPoint v = new DataPoint(xi, yi);
values[i] = v;
}
series = new LineGraphSeries<DataPoint>(values);
graph2.addSeries(series);
}