How to change domain axis labeles in android plot?

一个人想着一个人 提交于 2019-12-12 04:54:56

问题


In my android plot, the domain values(that is the values displayed on the scale of the X axis) displayed currently are 0,1,2,3..... But I wanted a different order that is neither increasing or decreasing. The order that I want is 0, 26, 33, 12, 9 6, 23 ....(I already know this order and it is does not change.) How to I change the values displayed on the axis?


回答1:


The easiest way is to define a mapping of labels that corresponds to each index. For example if your longest series consists of 6 elements:

// domain label mapping 
final String[] domainMap =  {"111", "222", "333", "444", "555", "666"};

...

plot.setDomainValueFormat(new NumberFormat() {
    @Override
    public StringBuffer format(double value, StringBuffer buffer, FieldPosition field) {
        return new StringBuffer(domainMap[(int) value]);
    }

    @Override
    public StringBuffer format(long value, StringBuffer buffer, FieldPosition field) {
        return null;
    }

    @Override
    public Number parse(String string, ParsePosition position) {
        return null;
    }
});


来源:https://stackoverflow.com/questions/25348413/how-to-change-domain-axis-labeles-in-android-plot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!