I am using graphview library and trying to format label of graph to time in 'HH' format from millisecond. I give each x value of datapoint in series as millisecond which is really big like '1.442440833138E12'. And after that i make my custom LabelFormatter like below:
@Override
public String formatLabel(double value, boolean isValueX) {
if (isValueX) {
SimpleDateFormat format = new SimpleDateFormat("HH");
Date date = new Date((long) value);
Log.i("formatLabel", Double.toString(date.getTime()));
return format.format(date);
} else {
return super.formatLabel(value, isValueX);
}
}
But when i looked at my graph, it was not same to what i put in, like when i put millisecond equal to 07 hour, the graph showed 11 hour or 01 hour as i change using setNumHorizontalLabels. So i tried to find what was wrong, and when i put log output code up that formatLabel method, the log output was like below:
09-17 20:03:50.287 28093-28093/? I/formatLabel﹕ 1.44243E12
09-17 20:03:50.287 28093-28093/? I/formatLabel﹕ 1.44244E12
09-17 20:03:50.287 28093-28093/? I/formatLabel﹕ 1.44245E12
09-17 20:03:50.287 28093-28093/? I/formatLabel﹕ 1.44246E12
09-17 20:03:50.292 28093-28093/? I/formatLabel﹕ 1.44247E12
which is supposed to look like '1.442440833138E12'. I also tried to make custom DefaultFormatter with number precision with minimum '12' digits but result was same.
Can someone explain to me why this happens?
-------------------------------------------------------------------------------
Here's my code of adding datapoints into each series.
DataPoint[] data1=new DataPoint[SIZE] ;
for(int i=0;i<SIZE;i++)
{
data1=new DataPoint(new Date(time),value) ;
//test whether x prints all full millisecond
Log.i("formatLabel", Double.toString(data1.getX()));
}
LineGraphSeries<DataPoint> series=new LineGraphSeries(data1) ;
when i saw a log output when i give each datapoint's x value with date, i get full millisecond notation like '1.442440833138E12'. But in my custom formatLabel instance above, it is truncated. I hope user can get my problem more clearly and give me some solution...