# Ruby Graphing/chart libraries?

**URL:** <https://rubytalk.org/t/ruby-graphing-chart-libraries/15084>\
**Category:** ruby-talk\
**Created:** [2 December 2004 00:33 UTC](https://rubytalk.org/t/ruby-graphing-chart-libraries/15084 "2004-12-02T00:33:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Williams2](https://avatars.discourse-cdn.com/v4/letter/c/48db29/32.png) [@Chris\_Williams2](https://rubytalk.org/u/Chris_Williams2)\
**Post date:** [2 December 2004 00:33 UTC](https://rubytalk.org/t/ruby-graphing-chart-libraries/15084/1 "2004-12-02T00:33:14Z")

</div>

Hi all,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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

---

<div class="post-metadata">

**Author:** ![Stoyan\_Zhekov](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@Stoyan\_Zhekov](https://rubytalk.org/u/Stoyan_Zhekov)\
**Post date:** [2 December 2004 01:16 UTC](https://rubytalk.org/t/ruby-graphing-chart-libraries/15084/2 "2004-12-02T01:16:14Z")

</div>

We are using ruby-gd [[http://raa.ruby-lang.org/project/ruby-gd/](http://raa.ruby-lang.org/project/ruby-gd/) ] and  
ruby-gdchart  
[[http://raa.ruby-lang.org/project/gdchart/](http://raa.ruby-lang.org/project/gdchart/) ] . ruby-gd is wrapper  
arroung lingd  
[[Short Term Loans | Boutell.co.uk | Borrow £50 - £2500 Instantly](http://www.boutell.com/gd/) ] 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)

> **···**
>
> 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.

---

<div class="post-metadata">

**Author:** ![George5](https://avatars.discourse-cdn.com/v4/letter/g/7c8e57/32.png) [@George5](https://rubytalk.org/u/George5)\
**Post date:** [2 December 2004 13:20 UTC](https://rubytalk.org/t/ruby-graphing-chart-libraries/15084/3 "2004-12-02T13:20:53Z")

</div>

Chris Williams wrote:

> Hi all,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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.de/wee/ehf](http://ntecs.de/wee/ehf)  
([http://www.ntecs.de/blog/Blog/FirstAppUsingWee.rdoc\](http://www.ntecs.de/blog/Blog/FirstAppUsingWee.rdoc%5C))

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

Two other options are:

&nbsp;&nbsp;&nbsp;gd-graph: [http://www.ntecs.de/viewcvs/viewcvs/gd-graph/](http://www.ntecs.de/viewcvs/viewcvs/gd-graph/)  
&nbsp;&nbsp;&nbsp;ploticus: [http://www.ntecs.de/viewcvs/viewcvs/ruby-ploticus/](http://www.ntecs.de/viewcvs/viewcvs/ruby-ploticus/)

Regards,

&nbsp;&nbsp;&nbsp;Michael

> **···**
>
> ###############################################  
> &nbsp;&nbsp;&nbsp;g = IO.popen("gnuplot", "w+")
> 
> &nbsp;&nbsp;&nbsp;points1 =   
> &nbsp;&nbsp;&nbsp;points2 =
> 
> &nbsp;&nbsp;&nbsp;for i in 1..600  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;points1 \<\< [i, vg[i]]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;points2 \<\< [i, vd[i]]  
> &nbsp;&nbsp;&nbsp;end
> 
> &nbsp;&nbsp;&nbsp;g.puts "set terminal png transparent small size 640,480 " +  
> &nbsp;&nbsp;&nbsp;"xffffff x000000 x404040 " +  
> &nbsp;&nbsp;&nbsp;"x0ff00f xf00f0f x66cdaa xcdb5cd " +  
> &nbsp;&nbsp;&nbsp;"xadd8e6 x0000ff xdda0dd x9500d3"
> 
> &nbsp;&nbsp;&nbsp;g.puts "set autoscale y"  
> &nbsp;&nbsp;&nbsp;g.puts "set xrange [0:600]"  
> &nbsp;&nbsp;&nbsp;g.puts "set xlabel 'Monate'"  
> &nbsp;&nbsp;&nbsp;g.puts "set ylabel 'Euro'"  
> &nbsp;&nbsp;&nbsp;g.puts "set grid"  
> &nbsp;&nbsp;&nbsp;g.puts "set noborder"
> 
> &nbsp;&nbsp;&nbsp;s = (["'1' 1"] + (60..600).to\_enum(:step, 60).map {|i| "'#{i}' #{i}" }).join(",")  
> &nbsp;&nbsp;&nbsp;g.puts "set xtics (#{s})"  
> &nbsp;&nbsp;&nbsp;g.puts "set key on below"
> 
> &nbsp;&nbsp;&nbsp;g.puts "plot '-' title 'Guthaben' with filledcurves, '-' title 'Darlehen' with filledcurves"  
> &nbsp;&nbsp;&nbsp;g.puts points1.map{|v| v.join(" ")}.join("\n")  
> &nbsp;&nbsp;&nbsp;g.puts "\ne\n"  
> &nbsp;&nbsp;&nbsp;g.puts points2.map{|v| v.join(" ")}.join("\n")  
> &nbsp;&nbsp;&nbsp;g.puts "\ne"
> 
> &nbsp;&nbsp;&nbsp;g.close\_write  
> &nbsp;&nbsp;&nbsp;png = g.read  
> &nbsp;&nbsp;&nbsp;File.open('test.png', 'w+') {|f| f \<\< png}

---

<div class="post-metadata">

**Author:** ![Chris\_Williams2](https://avatars.discourse-cdn.com/v4/letter/c/48db29/32.png) [@Chris\_Williams2](https://rubytalk.org/u/Chris_Williams2)\
**Post date:** [2 December 2004 01:36 UTC](https://rubytalk.org/t/ruby-graphing-chart-libraries/15084/4 "2004-12-02T01:36:34Z")

</div>

> \> 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/project/ruby-gd/](http://raa.ruby-lang.org/project/ruby-gd/) ] and  
> ruby-gdchart  
> [[http://raa.ruby-lang.org/project/gdchart/](http://raa.ruby-lang.org/project/gdchart/) ] . ruby-gd is wrapper  
> arroung lingd  
> [[http://www.boutell.com/gd/](http://www.boutell.com/gd/) ] 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

> **···**
>
> > \<cwillia1@rochester.rr.com\> wrote:

---

<div class="post-metadata">

**Author:** ![Sam\_Goldman](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@Sam\_Goldman](https://rubytalk.org/u/Sam_Goldman)\
**Post date:** [2 December 2004 01:41 UTC](https://rubytalk.org/t/ruby-graphing-chart-libraries/15084/5 "2004-12-02T01:41:49Z")

</div>

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/SVG::Graph/](http://www.germane-software.com/software/SVG/SVG::Graph/)

- Sam

---

<div class="post-metadata">

**Author:** ![gabriele\_renzi](https://avatars.discourse-cdn.com/v4/letter/g/e19b73/32.png) [@gabriele\_renzi](https://rubytalk.org/u/gabriele_renzi)\
**Post date:** [2 December 2004 09:12 UTC](https://rubytalk.org/t/ruby-graphing-chart-libraries/15084/6 "2004-12-02T09:12:43Z")

</div>

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.)
> 
> [SVG::Graph](http://www.germane-software.com/software/SVG/SVG::Graph/)

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