Reputation: 1510
I have a date object with includes a level (y-axis), a type (colour) and a date (x-axis).
I understand that I can make a grouped barchart using MPAndroidChart but how do I change the x values to show the date?
Upvotes: 2
Views: 645
Reputation: 1111
Use an IAxisValueFormatter like so:
public class MyYAxisValueFormatter implements IAxisValueFormatter {
private SimpleDateFormat mFormat;
public MyAxisValueFormatter() {
// format values to 1 decimal digit
mFormat = new SimpleDateFormat("MMM dd");
}
@Override
public String getFormattedValue(float value, AxisBase axis) {
// "value" represents the position of the label on the axis (x or y)
return mFormat.format(value);
}
/** this is only needed if numbers are returned, else return 0 */
@Override
public int getDecimalDigits() { return 0; }
}
Upvotes: 2