[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby Graphing/chart libraries?

Chris Williams

12/2/2004 12:33:00 AM

Hi all,
I'm trying to set up a Ruby/Rails app at work and for a
great deal of the pages I'll need to display graphs and charts of data.
Does anyone know of a simple package that can create bar, x-y plot, pie,
and other basic charts in a usable format? (I'm speaking gif, jpg, png.
I like the looks of the SVG::Graph library, but SVG support doesn't come
with any of the browsers yet.)

Thanks,
Chris
5 Answers

zhekov

12/2/2004 1:16:00 AM

0

On Thu, 2 Dec 2004 09:33:14 +0900, Chris Williams
<cwillia1@rochester.rr.com> wrote:
> Does anyone know of a simple package that can create bar, x-y plot, pie,
> and other basic charts in a usable format? (I'm speaking gif, jpg, png.

We are using ruby-gd [ http://raa.ruby-lang.org/projec... ] and
ruby-gdchart
[ http://raa.ruby-lang.org/projec... ] . ruby-gd is wrapper
arroung lingd
[ http://www.boute... ] and ruby-gdchart is wrapper around gd
specially for graphs
(bar, pie etc.). Pretty easy to use. Just not enough docs and i couldnt make it
run on windows (maybe will work with cygwin, i tryed the mingw).
Sample code for cgi:

require "cgi"
require "GD"
require 'GDChart'

cgi = CGI.new
print cgi.header("type"=>"image/png")
gdc = GDChart.new

gdc.image_type = GDChart::PNG

gdc.title = "The Title"
gdc.title_size = GDChart::GIANT

gdc.xtitle = "X-axis"
gdc.ytitle = "Y-axis"

gdc.ExtColor = [ 0xFF3399, 0xFF9933, 0xFFEE33, 0x33FF33, 0x33FFCC, 0x9966FF ]
gdc.BGColor = 0xFFFFFF

data = [ 7, 11, 13, 17, 19, 23 ]
label = ['Value X','Value Y']

gdc.out_graph(600, 400, $stdout, GDChart::BAR3D, data.length, label, 1, data)


Chris Williams

12/2/2004 1:37:00 AM

0

> <cwillia1@rochester.rr.com> wrote:
> > Does anyone know of a simple package that can create bar, x-y plot,
pie,
> > and other basic charts in a usable format? (I'm speaking gif, jpg,
png.
>
> We are using ruby-gd [ http://raa.ruby-lang.org/projec... ] and
> ruby-gdchart
> [ http://raa.ruby-lang.org/projec... ] . ruby-gd is wrapper
> arroung lingd
> [ http://www.boute... ] and ruby-gdchart is wrapper around gd
> specially for graphs
> (bar, pie etc.). Pretty easy to use. Just not enough docs and i
couldnt
> make it
> run on windows (maybe will work with cygwin, i tryed the mingw).

I suppose I should add that I need it to work on Windows...

Chris



Sam Goldman

12/2/2004 1:42:00 AM

0

I haven't tried SVG::Graph, nor do I have a Windows machine on which to
test it, but you do! (I would also argue that SVG _is_ a usable format,
though perhaps many would disagree.)

http://www.germane-software.com/software/SVG/S...

- Sam


gabriele renzi

12/2/2004 9:08:00 AM

0

Sam Goldman ha scritto:
> I haven't tried SVG::Graph, nor do I have a Windows machine on which to
> test it, but you do! (I would also argue that SVG _is_ a usable format,
> though perhaps many would disagree.)
>
> http://www.germane-software.com/software/SVG/S...
>

works like a charm, and it generates really nice graphs with little code.

Michael Neumann

12/2/2004 1:21:00 PM

0

Chris Williams wrote:
> Hi all,
> I'm trying to set up a Ruby/Rails app at work and for a
> great deal of the pages I'll need to display graphs and charts of data.
> Does anyone know of a simple package that can create bar, x-y plot, pie,
> and other basic charts in a usable format? (I'm speaking gif, jpg, png.
> I like the looks of the SVG::Graph library, but SVG support doesn't come
> with any of the browsers yet.)

I've used gnuplot for this: http://ntecs....
(http://www.ntecs.de/blog/Blog/FirstAppUsi...)

Below is the code snippet that generates the diagram using gnuplot.

Two other options are:

gd-graph: http://www.ntecs.de/viewcvs/viewcvs...
ploticus: http://www.ntecs.de/viewcvs/viewcvs/ruby...

Regards,

Michael



###############################################
g = IO.popen("gnuplot", "w+")

points1 = []
points2 = []

for i in 1..600
points1 << [i, vg[i]]
points2 << [i, vd[i]]
end

g.puts "set terminal png transparent small size 640,480 " +
"xffffff x000000 x404040 " +
"x0ff00f xf00f0f x66cdaa xcdb5cd " +
"xadd8e6 x0000ff xdda0dd x9500d3"

g.puts "set autoscale y"
g.puts "set xrange [0:600]"
g.puts "set xlabel 'Monate'"
g.puts "set ylabel 'Euro'"
g.puts "set grid"
g.puts "set noborder"

s = (["'1' 1"] + (60..600).to_enum(:step, 60).map {|i| "'#{i}' #{i}"
}).join(",")
g.puts "set xtics (#{s})"
g.puts "set key on below"

g.puts "plot '-' title 'Guthaben' with filledcurves, '-' title
'Darlehen' with filledcurves"
g.puts points1.map{|v| v.join(" ")}.join("\n")
g.puts "\ne\n"
g.puts points2.map{|v| v.join(" ")}.join("\n")
g.puts "\ne"

g.close_write
png = g.read
File.open('test.png', 'w+') {|f| f << png}