我在我的应用程序中使用这个库:https ://github.com/jjoe64/GraphView-Demos用于绘制图表。这个库可以工作,但是当我想绘制新图表或重绘不工作时
我看到这个链接但不起作用: GraphView and resetData
我在活动中绘制图表的代码:
GraphViewData[] newData = new GraphViewData[arrayWeight.size()];
int i = 0;
String date_now = "";
for (Weight w : arrayWeight) {
i += 1;
date_now = w.getdate();
date_now = date_now.substring(8);
newData[arrayWeight.indexOf(w)] = new GraphViewData(
Integer.parseInt(date_now), w.getWeight());
}
GraphViewSeries exampleSeries = new GraphViewSeries(newData);
exampleSeries.resetData(newData);
GraphView graphView = new LineGraphView(this, "weight");
graphView.redrawAll();
graphView.setVerticalLabels(new String[] { "100", "50", "1" });
graphView.setShowLegend(true);
graphView.setBackgroundColor(Color.GRAY);
graphView.addSeries(exampleSeries); // data
LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
layout.addView(graphView);