Reputation: 69
I use AchartEngine to create a LineGraph.
I have the data from the database in the format:
dd-mm-yyyy count
for example:
01-05-2013 3
01-08-2013 7
01-11-2013 4
01-12-2013 15
...
code fragment
...
int values = new Date[myCursor.getCount()];
Date[] dat = new Date[myCursor.getCount()];
SimpleDateFormat dfIn = new SimpleDateFormat("yyyy-MM-dd");
do{
try {
dat[kk]=dfIn.parse(myCursor.getString(0));
values[kk]=myCursor.getInt(1);
}
catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
kk++;
}
while(myCursor.moveToNext());
...
TimeSeries series = new TimeSeries("Line1");
for( int i = 0; i < dat.length; i++)
{
series.add(datki[i], values[i]);
}
I have a questions:
Dates and values I hold in separate tables. How can I add to TimeSeries this data ??? Is it possible to add the date in the format mm-yyyy ???
Please help
Upvotes: 1
Views: 925
Reputation: 3255
If using chartfactory :
intent = ChartFactory.getTimeChartIntent(this, getDateDemoDataset(), getDemoRenderer(), "MM-yyyy");
If using timechart:
TimeChart chart = new TimeChart(dataset, renderer);
chart.setDateFormat("MM-yyyy");
Upvotes: 2