Time Series Data Not Being Interpreted Properly
I'm trying to create a simple line chart using a time series. The problem is that androidplot is not properly displaying the time values from the array, i.e. the dates are off. The
Solution 1:
I believe the problem is that you are uniformly subdividing your domain (XYStepMode.SUBDIVIDE) but because your xVals are epoch values they are not uniformly distributed; the milliseconds between Jan 1, 2001 and Feb 1, 2001 is not the same as the milliseconds between Feb 1, 2001 and Mar 1, 2001, etc. which causes the discrepancy.
What I would suggest is to use i as your domain values instead of epoch values and then use i to lookup the correct epoch value in your domain value format code. This would involve making 2 changes. First, to use i as your f(x):
// I've just removed the 'years' param here, which tells SimpleXYSeries// to use an implicit value of 'i' for getY(i).XYSeriesseries1=newSimpleXYSeries(Arrays.asList(weights),"Weight");
And then change your format method to this:
@OverridepublicStringBufferformat(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
int i = ((Number) obj).intValue();
Date date = years[i];
Log.d(TAG, "formatting date=" + newSimpleDateFormat("MMMM dd, yyyy").format(date));
return dateFormat.format(date, toAppendTo, pos);
}
Post a Comment for "Time Series Data Not Being Interpreted Properly"