如何在android中绘制带有Time的x轴和另一个的图形?

Spa*_*lug 3 java android graph android-graphview

我想绘制时间值的关系图,其中时间(小时)在x轴上,值应在y轴上.有没有图书馆可以做到这一点?我尝试使用achartengine http://wptrafficanalyzer.in/blog/android-drawing-time-chart-with-timeseries-in-achartengine/,但没有多大帮助.

app*_*ter 5

您可以使用GraphView执行此操作.

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

https://github.com/jjoe64/GraphView

你必须使用一个Custom label formatter.有一个例子,其中X值显示为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
   }
};
Run Code Online (Sandbox Code Playgroud)

根据您的目的修改它应该很容易.