# Creating graph using Ruport

**URL:** <https://www.ruby-forum.com/t/creating-graph-using-ruport/130323>\
**Category:** Rails\
**Created:** [February 27, 2008, 11:20am UTC](https://www.ruby-forum.com/t/creating-graph-using-ruport/130323 "2008-02-27T11:20:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![seena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6de8d8/32.png) [@seena](https://www.ruby-forum.com/u/seena)\
**Post date:** [February 27, 2008, 11:20am UTC](https://www.ruby-forum.com/t/creating-graph-using-ruport/130323/1 "2008-02-27T11:20:41Z")

</div>

hi,  
cud anybody plz tell how to veiw or show a graph that has been created  
using the ruport gem…  
i have created the graph n report refering  
“[http://ruportbook.com/introducing\_ruport.html](http://ruportbook.com/introducing_ruport.html)”. but at the end it is  
not showing the graph on the browser.

---

<div class="post-metadata">

**Author:** ![seena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6de8d8/32.png) [@seena](https://www.ruby-forum.com/u/seena)\
**Post date:** [February 27, 2008, 7:47pm UTC](https://www.ruby-forum.com/t/creating-graph-using-ruport/130323/2 "2008-02-27T19:47:26Z")

</div>

This looks like something I can do. After much installation I try this  
simple example and get the following error. I did find a simple example  
that creates a pdf file, but I’d really like to make a graph. Any ideas  
on what I have misconfigured?

This is on an iMac G5 with 3g of memory and lots of disk space.

/Library/Ruby/Gems/1.8/gems/ruport-util-0.13.0/lib/ruport/util/report.rb:117:in  
`method_missing': undefined method`draw\_graph’ for  
#GraphReportController:0x13e3dd8 (NoMethodError)  
from g2.rb:10:in `renderable_data' from /Library/Ruby/Gems/1.8/gems/ruport-1.4.0/lib/ruport/renderer.rb:175:in`old\_as’  
from  
/Library/Ruby/Gems/1.8/gems/ruport-1.4.0/lib/ruport/renderer.rb:336:in  
`render' from /Library/Ruby/Gems/1.8/gems/ruport-1.4.0/lib/ruport/renderer.rb:379:in`build’  
from  
/Library/Ruby/Gems/1.8/gems/ruport-1.4.0/lib/ruport/renderer.rb:335:in  
`render' from /Library/Ruby/Gems/1.8/gems/ruport-1.4.0/lib/ruport/renderer.rb:172:in`old\_as’  
from  
/Library/Ruby/Gems/1.8/gems/ruport-util-0.13.0/lib/ruport/util/report.rb:95:in  
`as' from g2.rb:17 from /Library/Ruby/Gems/1.8/gems/ruport-util-0.13.0/lib/ruport/util/report.rb:126:in`generate’  
from g2.rb:16

---

<div class="post-metadata">

**Author:** ![seena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6de8d8/32.png) [@seena](https://www.ruby-forum.com/u/seena)\
**Post date:** [February 27, 2008, 1:32pm UTC](https://www.ruby-forum.com/t/creating-graph-using-ruport/130323/3 "2008-02-27T13:32:39Z")

</div>

Seena N. wrote:

> hi,  
> cud anybody plz tell how to veiw or show a graph that has been created  
> using the ruport gem…  
> i have created the graph n report refering  
> “[http://ruportbook.com/introducing\_ruport.html](http://ruportbook.com/introducing_ruport.html)”. but at the end it is  
> not showing the graph on the browser.

the code:

this is the code i had written:------ for the reference

require ‘rubygems’  
require ‘ruport’  
require ‘ruport/util’

class GraphReportController \< Ruport::Report

renders\_as\_graph

def renderable\_data(format)

graph = Graph(%w[a b c d e])  
graph.series [1,2,3,4,5], “foo”  
graph.series [11,22,70,2,19], “bar”  
draw\_graph(graph,  
:title =\> “Graph”, :labels =\>“Label”)

# send\_data(graph.to\_blob, :disposition =\> ‘inline’, :type =\>

‘image/png’, :filename =\> “foo.png”)  
return graph  
end

end

GraphReportController.generate do |r|  
r.as(:png, :title =\> “My Graph”,  
:labels =\> {0 =\> ‘2003’, 2 =\> ‘2004’, 4 =\> ‘2005’},  
:file =\> “my\_graph.png”  
)  
end
