我想在X轴上使用一组DataTime值。
使用achartengine,我想在其上显示以下对象:
date1,
DATE2
等...
我已经用这些值设置了achartengine。
这是我的代码:
if (mChartView == null){
layout_chart = (LinearLayout) findViewById(R.id.chart);
mChartView = ChartFactory.getCombinedXYChartView(
Grafico_modello.this
, chart.getDataset()//mDataset
, chart.getRenderer()//mRenderer
, chart.getTypes() //types
);
}
//populating the object on the .getDataset method
for (i=0;i<name_label.length;i++){
var[i] = new XYSeries(name_label[i]);
for (j=0;j<grafico.length();j++){
int unix_time=0;
unix_time=grafico.getDays()[j];
var[i].add(unix_time
, grafico.getVariabili()
.get(unix_time)
.get(name_var[i]));
}
}
更新1:
答案 0 :(得分:1)
我想我解决了我的问题。这是代码。
//SETTING THE DATASET
TimeSeries[] var = new TimeSeries[7];
XYSeriesRenderer[] arrayRenderer = new XYSeriesRenderer[7];
for (i=0;i<name_label.length;i++){
var[i] = new TimeSeries(name_label[i]);
for (j=0;j<grafico.length();j++){
int unix_time=0;
unix_time=grafico.getDays()[j];
Date date = new Date ();
date.setTime((long)unix_time*1000);
var[i].add(date
, grafico.getVariabili()
.get(unix_time)
.get(name_var[i]));
}
arrayRenderer[i]= new XYSeriesRenderer();
}
//pioggia - celeste
arrayRenderer[0].setColor(Color.rgb(173, 216, 230));
//tmin - blu
arrayRenderer[1].setColor(Color.BLUE);
//tmax - rosso
arrayRenderer[2].setColor(Color.RED);
//sole - giallo
arrayRenderer[3].setColor(Color.YELLOW);
//vento - bianco
arrayRenderer[4].setColor(Color.WHITE);
//Umin - marrone
arrayRenderer[5].setColor(Color.rgb(165, 42, 42));
//Umax - verde
arrayRenderer[6].setColor(Color.GREEN);
}
//SETTING THE CHART
mChartView = ChartFactory.getTimeChartView(
Grafico_meteo.this
, mDataset//mDataset
, mRenderer//mRenderer
, null
);