0
votes

I am using android-graphview to display bar graph in android app. On X-axis I want to display labels as 'day-of-the-week,hour-of-the-day' like 'Mon,14.00'. So original x value(it may be date or time in milliseconds) in data point is totally done away with. I know we can do some customization in setLabelFormatter, but as far as I understand you can do some append to original value, not totally remove it. Is there a way out for it?

1

1 Answers

0
votes

use the DefaultLabelFormatter override the format method and call the super implementation. then you can append your text to the string.

Example:

graph.getGridLabelRenderer().setLabelFormatter(new DefaultLabelFormatter() {
        @Override
        public String formatLabel(double value, boolean isValueX) {
            if (isValueX) {
                // show normal x values
                return super.formatLabel(value, isValueX);
            } else {
                // show currency for y values
                return super.formatLabel(value, isValueX) + " €";
            }
        }
    });