AndroidPlot:我如何更改域数据?
我实际上使用 AndroidPlot 库在我的 android 项目中使用一个简单的图表,但我不知道如何更改域区域的值。
更具体地说,这一行:
mySimpleXYPlot.setDomainValueFormat(new DecimalFormat("#"));
在网站上说我可以使用其他格式,这是真的,但如果我使用例如:
SimpleDateFormat("dd-MM-yyyy")
在图表中所有域值中都会出现“31-12-1969” 。
有人知道我如何更改该日期吗?或使用其他格式(如字符串)?
I use actually the AndroidPlot library to use a simple chart in my android project but I don't know how i can change the values of domain zone.
More specific, this line:
mySimpleXYPlot.setDomainValueFormat(new DecimalFormat("#"));
In the web site said that i can use another formats and its true, but if I use for example:
SimpleDateFormat("dd-MM-yyyy")
In the chart appears "31-12-1969" in all domain values.
Somebody know how I can change that date? or use another format (like String)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
迟到的答案,但也许对其他人有用。
我在这个问题上也遇到了困难,尤其是因为我是 Java 初学者。
我实现了一个自定义格式化程序。看起来有点丑陋的解决方案,但它有效。想法如下:
以下是一些代码片段。
首先是将数组索引转换为自定义标签字符串的类:
以下是我将其附加到绘图的方法:
这个技巧也适用于动态更新。
注意:Androidplot 似乎在绘制水平线时存在问题,因此如果您的数据具有相同的 Y 值,您可能会得到奇怪的结果,我已经就这个问题寻求帮助。
Late answer, but maybe will be useful to other people.
I also had a hard time with this issue, especially since I am Java beginner.
I implemented a custom formatter. Seems a bit ugly solution but it works. Idea is the following:
Here are some code snippets.
First is the class which transforms array index to a custom label String:
And here is how I attach it to the Plot:
This trick works also for dynamic updates.
NOTICE: Androidplot seems to have problems with drawing horizontal lines, so if your data has the same Y values, you might get strange results, I already asked for help on this issue.