In Files

  • test/test_sidestacked_bar.rb

TestGruffSideStackedBar

Public Instance Methods

setup() click to toggle source
 
               # File test/test_sidestacked_bar.rb, line 7
def setup
  @datasets = [
    [:Jimmy, [25, 36, 86, 39]],
    [:Charles, [80, 54, 67, 54]],
    [:Julie, [22, 29, 35, 38]],
    #[:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
    #[:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
    #["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
    ]
  @sample_labels = {
      0 => '5/6', 
      1 => '5/15', 
      2 => '5/24'
    }      

end
            
test_bar_graph() click to toggle source
 
               # File test/test_sidestacked_bar.rb, line 24
def test_bar_graph
  g = Gruff::SideStackedBar.new
  g.title = "Visual Stacked Bar Graph Test"
  g.labels = {
    0 => '5/6', 
    1 => '5/15', 
    2 => '5/24', 
    3 => '5/30', 
  }
  @datasets.each do |data|
    g.data(data[0], data[1])
  end
  g.write "test/output/side_stacked_bar_keynote.png"
end
            
test_bar_graph_small() click to toggle source
 
               # File test/test_sidestacked_bar.rb, line 40
def test_bar_graph_small
  g = Gruff::SideStackedBar.new(400)
  g.title = "Visual Stacked Bar Graph Test"
  g.labels = {
    0 => '5/6', 
    1 => '5/15', 
    2 => '5/24', 
    3 => '5/30', 
  }
  @datasets.each do |data|
    g.data(data[0], data[1])
  end
  g.write "test/output/side_stacked_bar_keynote_small.png"
end
            
test_should_space_long_left_labels_appropriately() click to toggle source
 
               # File test/test_sidestacked_bar.rb, line 61
def test_should_space_long_left_labels_appropriately
  g = Gruff::SideStackedBar.new
  g.title = "Stacked Bar Long Label"
  g.labels = {
    0 => 'September', 
    1 => 'Oct', 
    2 => 'Nov', 
    3 => 'Dec', 
  }
  @datasets.each do |data|
    g.data(data[0], data[1])
  end
  g.write "test/output/side_stacked_bar_long_label.png"
end
            
test_wide() click to toggle source
 
               # File test/test_sidestacked_bar.rb, line 55
def test_wide
  g = setup_basic_graph('800x400')
  g.title = "Wide SSBar"
  g.write "test/output/side_stacked_bar_wide.png"
end
            

Protected Instance Methods

setup_basic_graph(size=800) click to toggle source
 
               # File test/test_sidestacked_bar.rb, line 78
def setup_basic_graph(size=800)
  g = Gruff::SideStackedBar.new(size)
  g.title = "My Graph Title"
  g.labels = @sample_labels
  @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