amCharts [股票]图表
我一直在使用 amCharts 股票图表来显示来自雅虎财经 .csv 文件的数据,该文件以这种格式显示数据:(有效)
Date,Open,High,Low,Close,Volume,Adj Close
2011-07-27,617.18,620.95,604.75,607.22,3934400,607.22
2011-07-26,618.05,627.50,617.22,622.52,2342900,622.52
2011-07-25,613.36,625.41,613.00,618.98,3131600,618.98
但是现在我需要从 Google 财经获取数据,他们将数据格式化为这种格式(不工作)。
Date,Open,High,Low,Close,Volume
28-Jul-11,36.02,36.84,36.01,36.42,8870180
27-Jul-11,36.71,36.86,35.98,36.06,10395443
26-Jul-11,37.26,37.27,36.80,36.86,6366097
我相信雅虎和谷歌之间的数据格式不同是导致 amChart 不显示任何数字的原因,因为它无法读取文件。
如何格式化日期以使其正确读取值?
I've been using amCharts stocks charts to display data from Yahoo Finance .csv file which displays data in this format: (which works)
Date,Open,High,Low,Close,Volume,Adj Close
2011-07-27,617.18,620.95,604.75,607.22,3934400,607.22
2011-07-26,618.05,627.50,617.22,622.52,2342900,622.52
2011-07-25,613.36,625.41,613.00,618.98,3131600,618.98
However now I need to get data from Google finance and they format they're data in this format (which isn't working).
Date,Open,High,Low,Close,Volume
28-Jul-11,36.02,36.84,36.01,36.42,8870180
27-Jul-11,36.71,36.86,35.98,36.06,10395443
26-Jul-11,37.26,37.27,36.80,36.86,6366097
I believe the data format different between Yahoo and Google is what's causing the amChart to not display any figures because it can't read the file.
How do I format the date to get it to read the values properly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您使用的是 amstock 图表 1.4.0.1。在 amstock_settings.xml 中,您需要编辑日期格式设置。默认情况下,它使用 YYYY-MM-DD,我根据您的示例假设这是雅虎财经 CSV 中的默认日期格式。 Google 财经的日期格式为 DD-Mon-YY,根据 AmCharts,“Mon”不是有效符号。您可以尝试将设置更改为DD-Mon-YY,看看它是否有效,如果不行,您可能需要使用程序(例如java)将csv中的日期值更改为YYYY-MM-DD。
I'll assume that you are using amstock charts 1.4.0.1. In your amstock_settings.xml you need to edit the date format settings. By default it is using YYYY-MM-DD which I assume based from your example is Yahoo Finance's default date format in their CSV. Google finance's date format is DD-Mon-YY which based on AmCharts 'Mon' is not a valid symbol. You can try to change the settings to DD-Mon-YY and see if it works if not you may need to use a program(e.g. java) to change the date values in csv into YYYY-MM-DD.
amStock 不支持 28-Jul-11 格式的日期。您需要构建一个服务器端代理脚本,将所有日期转换为某种受支持的格式,例如 2011-07-28。
这是 PHP 中的一个:
amStock does not support dates in 28-Jul-11 format. You will need to build a server-side proxy script that converts all dates to some supported format like 2011-07-28.
Here's one in PHP: