Вопрос

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