3

I want to plot a Time vs value graph where time (in hours) is on the x-axis and the Values should be on the y-axis. Is there any library to do this? I tried using achartengine http://wptrafficanalyzer.in/blog/android-drawing-time-chart-with-timeseries-in-achartengine/ but not much helpful.

Sparkplug
  • 485
  • 7
  • 21

1 Answers1

5

you can use GraphView for doing this.

http://www.jjoe64.com/p/graphview-library.html

https://github.com/jjoe64/GraphView

you have to use a Custom label formatter. There's an example where the X-values are displayed as DateTime.

GraphView graphView = new LineGraphView(this, "example") {
   @Override
   protected String formatLabel(double value, boolean isValueX) {
      if (isValueX) {
         // convert unix time to human time
         return dateTimeFormatter.format(new Date((long) value*1000));
      } else return super.formatLabel(value, isValueX); // let the y-value be normal-formatted
   }
};

It should be easy to modify this to your purpose.

appsthatmatter
  • 6,347
  • 3
  • 36
  • 40
  • When viewing data plotted in a time axis you expect the x-axis labels to have nice, round values: full hours, 30 minutes, etc. This is not possible with your solution that labels arbitrarily. – gcasar Jun 12 '15 at 08:48
  • 1
    Where can I find the `LineGraphView`? – mr5 Dec 04 '15 at 07:35