我在Android项目中设置了GraphView。不幸的是,我似乎无法在我的图表上绘制一系列点数。它只绘制一个。
它检查的数组大小是3. DayAmount的值是1!3,1 * 5等,字符串将其拆分为1,3等,并将它们转换为x,y坐标。这很好。
我只是想不通为什么循环(generateData)似乎只在我的图上加载一个点?
以下是我的图表设置:
GraphView graph = (GraphView) findViewById(R.id.graph);
mSeries = new LineGraphSeries<>(generateData());
StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph);
graph.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);
mSeries.setDrawDataPoints(true);
graph.addSeries(mSeries);
graph.getViewport().setMinX(0);
graph.getViewport().setMaxX(20);
graph.getViewport().setMinY(0);
graph.getViewport().setMaxY(20);
graph.getViewport().setYAxisBoundsManual(true);
graph.getViewport().setXAxisBoundsManual(true);
生成数据:
private DataPoint[] generateData() {
int size = DayAmount.size();
Log.e(TAG, "Size of ARRAY" + size);
DataPoint[] values = new DataPoint[size];
for (int i=0; i < size; i++) {
String daysAmounts = DayAmount.get(i);
String[] splitthem = daysAmounts.split("!");
Integer x = Integer.parseInt(splitthem[0]);
Integer y = Integer.parseInt(splitthem[1]);
Log.e(TAG, "X, Y" + x + " - " + y);
DataPoint v = new DataPoint(x, y);
values[i] = v;
Log.e(TAG, "All Values" + v);
}
return values;
}
答案 0 :(得分:1)