Class: Tuftify::Graph
Overview
Basic Graph class.
Instance Attribute Summary collapse
-
#canvas ⇒ Object
Returns the value of attribute canvas.
-
#font_size ⇒ Object
Returns the value of attribute font_size.
-
#height ⇒ Object
Returns the value of attribute height.
-
#resolution ⇒ Object
Returns the value of attribute resolution.
-
#title ⇒ Object
Returns the value of attribute title.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #add_layer(data, options = {}) ⇒ Object
- #draw ⇒ Object
-
#initialize(width, height) ⇒ Graph
constructor
A new instance of Graph.
Constructor Details
#initialize(width, height) ⇒ Graph
Returns a new instance of Graph.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tuftify/graph.rb', line 14 def initialize(width, height) @width = width @height = height @font_size = 9 @resolution = 72.0 d = "#{@resolution}x#{@resolution}" @canvas = Magick::Image.new(@width, @height) { self.background_color = 'white' self.density = d } @details = {:canvas => @canvas, :height => height, :width => width} @graph_layer = [] end |
Instance Attribute Details
#canvas ⇒ Object
Returns the value of attribute canvas.
10 11 12 |
# File 'lib/tuftify/graph.rb', line 10 def canvas @canvas end |
#font_size ⇒ Object
Returns the value of attribute font_size.
9 10 11 |
# File 'lib/tuftify/graph.rb', line 9 def font_size @font_size end |
#height ⇒ Object
Returns the value of attribute height.
8 9 10 |
# File 'lib/tuftify/graph.rb', line 8 def height @height end |
#resolution ⇒ Object
Returns the value of attribute resolution.
9 10 11 |
# File 'lib/tuftify/graph.rb', line 9 def resolution @resolution end |
#title ⇒ Object
Returns the value of attribute title.
11 12 13 |
# File 'lib/tuftify/graph.rb', line 11 def title @title end |
#width ⇒ Object
Returns the value of attribute width.
8 9 10 |
# File 'lib/tuftify/graph.rb', line 8 def width @width end |
Instance Method Details
#add_layer(data, options = {}) ⇒ Object
31 32 33 |
# File 'lib/tuftify/graph.rb', line 31 def add_layer(data, = {}) @graph_layer << Tuftify::GraphLayer.new(data, @details, ) end |
#draw ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/tuftify/graph.rb', line 35 def draw @graph_layer.each do |layer| layer.draw end return @canvas end |