如何用x轴绘制时间图,在android中绘制另一个图?
我想绘制时间与值的关系图,其中时间(以小时为单位)在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
你必须使用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 } };
根据您的目的修改它应该很容易。