Skip to content Skip to sidebar Skip to footer

Androidplot: Domain Labels From 1 To 11

I've implemented AndroidPlot in my app and it works fine, apart from the X-axis labels, which they go from 0 to ten. I'd like to display 1 to eleven. Besides, the labels on the Y-a

Solution 1:

You can apply a custom formatter to make the labels print whatever you want. In your case, I believe something like this should work:

plot.setDomainValueFormat(new NumberFormat() {

            @Override
            public StringBuffer format(double d, StringBuffer sb, FieldPosition fp) {
                return sb.append((d + 1) + ""); // shortcut to convert d+1 into a String
            }

            // unused
            @Override
            public StringBuffer format(long l, StringBuffer stringBuffer, FieldPosition fieldPosition) { return null;}

            // unused
            @Override
            public Number parse(String s, ParsePosition parsePosition) { return null;}
});

Post a Comment for "Androidplot: Domain Labels From 1 To 11"