gpt4 book ai didi

java - 如何在 android 中用 x 轴上的时间和另一个轴上的值绘制图表?

转载 作者:太空宇宙 更新时间:2023-11-03 12:57:49 25 4
gpt4 key购买 nike

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

最佳答案

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

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

https://github.com/jjoe64/GraphView

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

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

关于java - 如何在 android 中用 x 轴上的时间和另一个轴上的值绘制图表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16850789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com