如何用x轴绘制时间图,在android中绘制另一个图?

时间:2022-04-20 01:02:02

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.

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

1 个解决方案

#1


5  

you can use GraphView for doing this.

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

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

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

https://github.com/jjoe64/GraphView

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.

你必须使用自定义标签格式化程序。有一个例子,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
   }
};

It should be easy to modify this to your purpose.

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

#1


5  

you can use GraphView for doing this.

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

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

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

https://github.com/jjoe64/GraphView

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.

你必须使用自定义标签格式化程序。有一个例子,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
   }
};

It should be easy to modify this to your purpose.

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