I'm using GraphView library (see: https://github.com/jjoe64/GraphView or http://www.jjoe64.com/p/graphview-library.html)
But I would like to use Date/Time for the X-as. Does anyone knows a easy way to accomplish this or can anyone push me in the right direction?
This is the correct way to do this
You just have to use the unix timestamp (seconds from 1.01.1970) as x value.
Then you can set a custom label formatter and convert the unix timestamp to a String:
final java.text.DateFormat dateTimeFormatter = DateFormat.getTimeFormat(mActivity);
LineGraphView graphView = new LineGraphView(mActivity, entry.getValue()) {
@Override
protected String formatLabel(double value, boolean isValueX) {
if (isValueX) {
// transform number to time
return dateTimeFormatter.format(new Date((long) value*1000));
} else {
return super.formatLabel(value, isValueX);
}
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With