MPAndroid 图表按日期

MPAndroid Chart by Date

我有一个日期对象,其中包含级别(y 轴)、类型(颜色)和日期(x 轴)。

我知道我可以使用 MPAndroidChart 制作 grouped barchart,但我如何更改 x 值以显示日期?

像这样使用 IAxisValueFormatter:

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; }
}