In Files

  • test/test_spider.rb

TestGruffSpider

Public Instance Methods

setup() click to toggle source
 
               # File test/test_spider.rb, line 7
  def setup
    @datasets = [
      [:Strength, [10]],
      [:Dexterity, [16]],
      [:Constitution, [12]],
      [:Intelligence, [12]],
      [:Wisdom, [10]],
      ["Charisma", [16]],
      ]

#     @datasets = [
#       [:Darren, [25]],
#       [:Chris, [80]],
#       [:Egbert, [22]],
#       [:Adam, [95]],
#       [:Bill, [90]],
#       ["Frank", [5]],
#       ["Zero", [0]],
#       ]
  end
            
test_label_size() click to toggle source
 
               # File test/test_spider.rb, line 90
def test_label_size
  g = setup_basic_graph()
  g.title = "Spider With Small Legend"
  g.legend_font_size = 10
  g.write("test/output/spider_legend.png")
  
  g = setup_basic_graph(400)
  g.title = "Small spider With Small Legend"
  g.legend_font_size = 10
  g.write("test/output/spider_legend_small.png")
end
            
test_lots_of_data() click to toggle source
 
               # File test/test_spider.rb, line 176
def test_lots_of_data
  g = Gruff::Spider.new(10)
  @datasets = [[:a, [1]], [:b, [5]], [:c, [3]], [:d, [9]], [:e, [4]],
               [:f, [7]], [:g, [0]], [:h, [4]], [:i, [6]], [:j, [0]],
               [:k, [4]], [:l, [8]]]
 
  @datasets.each do |data|
    g.data(data[0], data[1])
  end
               
  g.title = "Sample Data"
  g.write("test/output/spider_lots_of_data.png")
end
            
test_lots_of_data_with_large_names() click to toggle source
 
               # File test/test_spider.rb, line 190
def test_lots_of_data_with_large_names
  g = Gruff::Spider.new(10)
  @datasets = [[:anteaters, [1]], [:bulls, [5]], [:cats, [3]], [:dogs, [9]], [:elephants, [4]],
               [:frogs, [7]], [:giraffes, [0]], [:hamsters, [4]], [:iguanas, [6]], 
               [:jaguar, [0]], [:kangaroo, [4]], [:locust, [8]]]
 
  @datasets.each do |data|
    g.data(data[0], data[1])
  end
               
  g.title = "Zoo Inventory"
  g.write("test/output/spider_lots_of_data_normal_names.png")
end
            
test_no_axes() click to toggle source
 
               # File test/test_spider.rb, line 115
def test_no_axes
  g = Gruff::Spider.new(20)
  g.title = "Look ma, no axes"
  g.hide_axes = true
  @datasets.each do |data|
   g.data(data[0], data[1])
  end
  g.write("test/output/spider_no_axes.png")

end
            
test_no_print() click to toggle source
 
               # File test/test_spider.rb, line 126
def test_no_print
  g = Gruff::Spider.new(20)
  g.title = "Should not print"
  g.hide_text = true
  @datasets.each do |data|
    g.data(data[0], data[1])
  end
  g.write("test/output/spider_no_print.png")
end
            
test_overlay() click to toggle source
 
               # File test/test_spider.rb, line 148
def test_overlay
  g = Gruff::Spider.new(20)
  g.title = "George (blue) vs Sarah (white)"
  @datasets.each do |data|
    g.data(data[0], data[1])
  end
  g.write("test/output/spider_overlay_1.png")
  
  g = Gruff::Spider.new(20)
  g.title = "Transparent background"
  g.hide_text = true
  g.hide_axes = true
  g.transparent_background = true
  @datasets = [
    [:Strength, [18]],
    [:Dexterity, [10]],
    [:Constitution, [18]],
    [:Intelligence, [8]],
    [:Wisdom, [14]],
    ["Charisma", [4]],
    ]   
  @datasets.each do |data|
    g.data(data[0], data[1])
  end
  g.marker_color = "#4F6EFF"
  g.write("test/output/spider_overlay_2.png")
end
            
test_pie_graph_equal() click to toggle source
 
               # File test/test_spider.rb, line 62
def test_pie_graph_equal
  g = Gruff::Spider.new(50)
  g.title = "Spider Graph Equal"
      
  g.data(:Bert, [41])
  g.data(:Adam, [41])
  g.data(:Joe, [41])

  g.write("test/output/spider_equal.png")
end
            
test_pie_graph_small() click to toggle source
 
               # File test/test_spider.rb, line 39
def test_pie_graph_small
  g = Gruff::Spider.new(20, 400)
  g.title = "Visual Spider Graph Test Small"
  @datasets.each do |data|
    g.data(data[0], data[1])
  end

  # Default theme
  g.write("test/output/spider_small.png")
end
            
test_pie_graph_zero() click to toggle source
 
               # File test/test_spider.rb, line 73
def test_pie_graph_zero
  g = Gruff::Spider.new(2)
  g.title = "Pie Graph Two One Zero"
      
  g.data(:Bert, [0])
  g.data(:Adam, [1])
  g.data(:Sam,  [2])

  g.write("test/output/spider_zero.png")
end
            
test_spider_graph() click to toggle source
 
               # File test/test_spider.rb, line 28
def test_spider_graph
  g = Gruff::Spider.new(20)
  g.title = "Spider Graph Test"
  @datasets.each do |data|
    g.data(data[0], data[1])
  end

  # Default theme
  g.write("test/output/spider_keynote.png")
end
            
test_spider_graph_nearly_equal() click to toggle source
 
               # File test/test_spider.rb, line 50
  def test_spider_graph_nearly_equal
    g = Gruff::Spider.new(50)
    g.title = "Spider Graph Nearly Equal"
    
    g.data(:Blake, [41])
    g.data(:Aaron, [42])
    g.data(:Grouch, [40])
#    g.data(:Snuffleupagus, [43])

    g.write("test/output/spider_nearly_equal.png")
  end
            
test_theme_37signals() click to toggle source
 
               # File test/test_spider.rb, line 102
def test_theme_37signals
  g = Gruff::Spider.new(20)
  g.title = "Spider Graph Test"
  @datasets.each do |data|
   g.data(data[0], data[1])
  end

  g.theme_37signals

  # Default theme
  g.write("test/output/spider_37signals.png")
end
            
test_transparency() click to toggle source
 
               # File test/test_spider.rb, line 136
def test_transparency
  g = Gruff::Spider.new(20)
  g.title = "Transparent background"
  g.hide_text = true
  g.transparent_background = true
  g.hide_axes = true
  @datasets.each do |data|
    g.data(data[0], data[1])
  end
  g.write("test/output/spider_no_background.png")
end
            
test_wide() click to toggle source
 
               # File test/test_spider.rb, line 84
def test_wide
  g = setup_basic_graph('800x400')
  g.title = "Wide spider"
  g.write("test/output/spider_wide.png")
end
            

Protected Instance Methods

setup_basic_graph(size=800, max = 20) click to toggle source
 
               # File test/test_spider.rb, line 207
def setup_basic_graph(size=800, max = 20)
  g = Gruff::Spider.new(max, size)
  g.title = "My Graph Title"
  @datasets.each do |data|
    g.data(data[0], data[1])
  end
  return g
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.

blog comments powered by Disqus