문제

I use the awsome GraphView lib to create a graph in my Android App. But I have a problem. I only want integer values and not double values. I try to custom label formatter but it does not function... I think I'm doing something wrong but I don't know what.... Can someone give me a way to explore? (or may be the solution!!!)

thx!

도움이 되었습니까?

해결책

Use the custom label formatter and just cast the value to Integer.

Try something like that:

GraphView graphView = new LineGraphView(this, "example") {
   @Override
   protected String formatLabel(double value, boolean isValueX) {
      // return as Integer
      return ""+((int) value);
   }
};

다른 팁

Well now formatLabel is deprecated, so overriding it directly is no longer correct.

In newer versions of GraphView, the correct way is to use Custom Label Formatter:

graphView.setCustomLabelFormatter(new CustomLabelFormatter() {
    @Override
    public String formatLabel(double value, boolean isValueX) {
        // return as Integer
        return ""+((int) value);
    }
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top