Class: Ruport::Formatter::Graph::Gruff
- Inherits:
-
Ruport::Formatter
- Object
- Ruport::Formatter
- Ruport::Formatter::Graph::Gruff
- Defined in:
- lib/ruport/util/graph/gruff.rb
Instance Method Summary collapse
- #apply_template ⇒ Object
- #build_graph ⇒ Object
-
#initialize ⇒ Gruff
constructor
A new instance of Gruff.
-
#save_output(filename) ⇒ Object
Save the output to a file.
Constructor Details
Instance Method Details
#apply_template ⇒ Object
12 13 14 15 16 17 |
# File 'lib/ruport/util/graph/gruff.rb', line 12 def apply_template .min = template.y_min .max = template.y_max .width = template.width .height = template.height end |
#build_graph ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruport/util/graph/gruff.rb', line 19 def build_graph graph = ::Gruff::Line.new("#{.width || 800}x#{.height || 600}") graph.title = .title if .title graph.labels = .labels if .labels data.each do |r| graph.data(r.gid,r.to_a) end graph.maximum_value = .max if .max graph.minimum_value = .min if .min output << graph.to_blob(format.to_s) end |
#save_output(filename) ⇒ Object
Save the output to a file.
34 35 36 |
# File 'lib/ruport/util/graph/gruff.rb', line 34 def save_output(filename) File.open(filename,"wb") {|f| f << output } end |