好吧,我尝试在我的应用程序中实现电池图大约是 1 次。只是一个监控一天中电池状态的图表(更多)...我找到了 AchartEngine 框架,但实际上,文件太多了我和我不明白我必须改变什么才能拥有我想要的……我打开了演示文件夹,我找到了一些示例图。我认为在我的情况下最好的是Average Temperature
示例图。这是它的代码
/**
* Executes the chart demo.
*
* @param context the context
* @return the built intent
*/
public Intent execute(Context context) {
String[] titles = new String[] { "Crete" };
List<double[]> x = new ArrayList<double[]>();
for (int i = 0; i < titles.length; i++) {
x.add(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); // X Values
}
List<double[]> values = new ArrayList<double[]>();
values.add(new double[] { 10, 10, 12, 15, 20, 24, 26, 26, 23, 18, 14, 11 }); // Y Values
int[] colors = new int[] { Color.BLUE, Color.GREEN, Color.CYAN, Color.YELLOW };
PointStyle[] styles = new PointStyle[] { PointStyle.CIRCLE, PointStyle.DIAMOND,
PointStyle.TRIANGLE, PointStyle.SQUARE };
XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);
int length = renderer.getSeriesRendererCount();
for (int i = 0; i < length; i++) {
((XYSeriesRenderer) renderer.getSeriesRendererAt(i)).setFillPoints(true);
}
setChartSettings(renderer, "Average temperature", "Month", "Temperature", 0.5, 12.5, -10, 40,
Color.LTGRAY, Color.LTGRAY);
renderer.setXLabels(12);
renderer.setYLabels(10);
renderer.setShowGrid(true);
renderer.setXLabelsAlign(Align.RIGHT);
renderer.setYLabelsAlign(Align.RIGHT);
renderer.setZoomButtonsVisible(true);
renderer.setPanLimits(new double[] { -10, 20, -10, 40 });
renderer.setZoomLimits(new double[] { -10, 20, -10, 40 });
XYMultipleSeriesDataset dataset = buildDataset(titles, x, values);
XYSeries series = dataset.getSeriesAt(0);
series.addAnnotation("Vacation", 6, 30);
Intent intent = ChartFactory.getLineChartIntent(context, dataset, renderer,
"Average temperature");
return intent;
}
}
如果我的想法是正确的,我想要的是
values.add(new double[] { batterylevel }); // Chart line Values
正确的?