3

I need some help, I want to show in my GraphView date by DD/MM/YYYY in axis x. And in the y axis number(Integer)... how can I add the date to the axis X it only get int. (I use this library http://android-graphview.org/ )

Avivhadsa
  • 45
  • 1
  • 4

2 Answers2

4

There's a post about that topic in the documentation:

http://www.android-graphview.org/documentation/label-formatter

There is also a specific example for dates in axis - "Use Dates as Labels".

If you set the X value as Date object or as unix epoch (millis from 1970-01-01) then you can easily use this predefined label formatter:

graph.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(getActivity()));
appsthatmatter
  • 6,347
  • 3
  • 36
  • 40
2

You can use a custom list of horizontal labels, like this:

barGraphView.setHorizontalLabels(new String[]{"1/1/1970", "1/2/1970", "1/3/1970"});

I did something similar by constructing the String array using a for-loop.

nt-complete
  • 519
  • 3
  • 14