Class: Tuftify::GraphLayer
- Inherits:
-
Object
- Object
- Tuftify::GraphLayer
- Includes:
- Magick
- Defined in:
- lib/tuftify/graph_layer.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#options ⇒ Object
Returns the value of attribute options.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(data, details, options = {}) ⇒ GraphLayer
constructor
A new instance of GraphLayer.
Constructor Details
#initialize(data, details, options = {}) ⇒ GraphLayer
Returns a new instance of GraphLayer.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/tuftify/graph_layer.rb', line 12 def initialize(data, details, = {}) @options = {:title => 'Graph', :font_family =>'Helvetica', :fill => 'black', :pointsize => 12, :title_pointsize => 18, :categories_pointsize => 12, :gravity => NorthGravity, :stroke => 'white' } @height = details[:height] @width = details[:width] @options = @options.merge @data = data.collect {|i| [i[0], i[1].to_f]} @panels = {} title = Tuftify::TitlePanel.new(@options.delete(:title), @options[:title_pointsize], details, @options) @panels[:title] = title = @width / @data.length categories = [] categories = @data.collect { |value| value[0].to_s} if @options[:categories].nil? categories = @options[:categories] unless @options[:categories].nil? @panels[:category_axis] = Tuftify::CategoryAxis.new(categories,0, @options[:categories_pointsize],details,,@options) @height_graph = @height - (title.height + @panels[:category_axis].height) @panels[:graph_area] = Tuftify::GraphAreaPanel.new(data, 0, title.height, @width, @height_graph, details[:canvas], @options) end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
10 11 12 |
# File 'lib/tuftify/graph_layer.rb', line 10 def height @height end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/tuftify/graph_layer.rb', line 9 def @options end |
#width ⇒ Object
Returns the value of attribute width.
10 11 12 |
# File 'lib/tuftify/graph_layer.rb', line 10 def width @width end |
Instance Method Details
#draw ⇒ Object
45 46 47 48 49 |
# File 'lib/tuftify/graph_layer.rb', line 45 def draw @panels[:title].draw @panels[:graph_area].draw @panels[:category_axis].draw end |