Search code examples
androidandroid-graphview

Only Integer values when using the GraphView library


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!


Solution

  • 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);
       }
    };