2
你好AChartEngine對我來說是非常新的,所以任何幫助都是值得歡迎的。我想要做的是顯示來自我的數據庫的2個數據,這些數據是BMI結果以及用戶保存他/她的BMI結果時的日期。我現在不知道該怎麼做。但我有是這樣的:如何整合AChartEngine與SQLite數據庫的數據?
我的代碼: 公共類ViewBMIData延伸活動{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.viewbmidata);
//TextView tv1 = (TextView) findViewById (R.id.tvBMIData);
//TextView tv2 = (TextView) findViewById (R.id.tvBMIDate);
BMICalculatorDB info = new BMICalculatorDB(this);
info.open();
String data1 = info.getBMIDataData();
String data2 = info.getBMIDateData();
for (int i = 1; data1 == null; i++) {
double x = Double.parseDouble(data1);
double y = Double.parseDouble(data2);
}
info.close();
//tv1.setText(data1);
//tv2.setText(data2);
}
這段代碼是什麼我從教程找到,但不知道如何做到這一點:
public Intent getIntent(Context context){
// Bar 1
int[] y = { 124, 135, 443, 456, 234, 123, 342, 134, 123, 643, 234, 274 };
CategorySeries series = new CategorySeries("BMI");
for (int i = 0; i < y.length; i++) {
series.add("Bar " + (i+1), y[i]);
}
// Bar 2
int[] y2 = { 224, 235, 243, 256, 234, 223, 242, 234, 223, 243, 234, 274 };
CategorySeries series2 = new CategorySeries("BMR");
for (int i = 0; i < y.length; i++) {
series2.add("Bar " + (i+1), y2[i]);
}
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
dataset.addSeries(series.toXYSeries());
dataset.addSeries(series2.toXYSeries());
// This is how the "Graph" itself will look like
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
mRenderer.setChartTitle("BMI and BMR Statistics");
mRenderer.setXTitle("DATE");
mRenderer.setYTitle("BMI");
mRenderer.setAxesColor(Color.GREEN);
mRenderer.setLabelsColor(Color.RED);
// Customize bar 1
XYSeriesRenderer renderer = new XYSeriesRenderer();
renderer.setDisplayChartValues(true);
renderer.setChartValuesSpacing((float) 0.5);
mRenderer.addSeriesRenderer(renderer);
// Customize bar 2
XYSeriesRenderer renderer2 = new XYSeriesRenderer();
renderer.setColor(Color.CYAN);
renderer.setDisplayChartValues(true);
renderer.setChartValuesSpacing((float) 0.5);
mRenderer.addSeriesRenderer(renderer2);
Intent intent = ChartFactory.getBarChartIntent(context, dataset,mRenderer, Type.DEFAULT);
return intent;
} */
請指導我這樣做。謝謝
是的,他們沒有從數據庫檢索數據的例子? – Dunkey
不「他們」不。他們沒有示例從文件或網絡中或從支持Android的直升機上檢索數據,或從... –
創建渲染器和數據集並開始向其中添加數據並不是什麼大事。 –