开发者

how do i create charts from a cvs file using ruby

csv sample:

Date,128,440,1024,Mixed 6/30/2010,342,-0.26%,-0.91开发者_如何学JAVA%,1.51%,-0.97% 6/24/2010,0.23%,0.50%,-1.34%,0.67%

i want to render this data in a multi-line graph


Well, you first need to parse the CSV. I suggest FasterCSV - the RDoc explains pretty much everything you need to know.

You'll need to have ImageMagick and RMagick installed, then you can use Gruff. Or if you've got an Internet connection on the machine you are running the script on, you can use Google Charts with this Ruby plugin. Or if you want to get back SVG, consider Scruffy.

The page about Gruff has a code sample showing how to create a multi-line graph. Basically, you need to collect together all the data you want in each line into an array. Looks basically like the primary thing you need to do is array mangling.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜