这行代码应该绘制一个图形。但它没有策划任何事情。它只是显示轴
This line of code is supposed to draw a graph. But it is not plotting anything. It is just showing the axes
我正在使用 jjoe64 graphview 库
//画图
GraphView graph = findViewById(R.id.plot);
graph.setVisibility(View.VISIBLE);
DataPoint[] data = new DataPoint[term];
for (int i=0;i<term;i++){
data[i] = new DataPoint(i+1,P * java.lang.Math.pow(1 + (r) / 100, i));
}
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(data);
graph.addSeries(series);
以下代码修复了它:
graph.removeAllSeries();
LineGraphSeries<DataPoint> series = new LineGraphSeries<>();
for (int i=1;i<=term;i++){
int x=i;
long y=Math.round(P * java.lang.Math.pow(1 + (r) / 100, i));
series.appendData(new DataPoint(x,y),true,term);
}
graph.addSeries(series);
我正在使用 jjoe64 graphview 库 //画图
GraphView graph = findViewById(R.id.plot);
graph.setVisibility(View.VISIBLE);
DataPoint[] data = new DataPoint[term];
for (int i=0;i<term;i++){
data[i] = new DataPoint(i+1,P * java.lang.Math.pow(1 + (r) / 100, i));
}
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(data);
graph.addSeries(series);
以下代码修复了它:
graph.removeAllSeries();
LineGraphSeries<DataPoint> series = new LineGraphSeries<>();
for (int i=1;i<=term;i++){
int x=i;
long y=Math.round(P * java.lang.Math.pow(1 + (r) / 100, i));
series.appendData(new DataPoint(x,y),true,term);
}
graph.addSeries(series);