Permalink
Browse files

* Merge branch 'themes'

  • Loading branch information...
2 parents 8c35469 + 46f4e71 commit 9c73a95d50f6eaad260e82588e7a02dac3cd1c9d @donv donv committed Nov 9, 2012
Showing with 120 additions and 114 deletions.
  1. +1 −0 lib/gruff.rb
  2. +7 −105 lib/gruff/base.rb
  3. +2 −1 lib/gruff/bullet.rb
  4. +102 −0 lib/gruff/themes.rb
  5. +2 −2 test/test_bar.rb
  6. +3 −3 test/test_line.rb
  7. +2 −2 test/test_pie.rb
  8. +1 −1 test/test_spider.rb
View
@@ -3,6 +3,7 @@
# Extra full path added to fix loading errors on some installations.
%w(
+ themes
base
area
bar
View
@@ -190,7 +190,7 @@ def initialize(target_width=DEFAULT_TARGET_WIDTH)
initialize_ivars
reset_themes
- theme_keynote
+ self.theme = Themes::KEYNOTE
end
# Set instance variables for this object.
@@ -316,126 +316,28 @@ def theme=(options)
render_background
end
- # A color scheme similar to the popular presentation software.
def theme_keynote
- # Colors
- @blue = '#6886B4'
- @yellow = '#FDD84E'
- @green = '#72AE6E'
- @red = '#D1695E'
- @purple = '#8A6EAF'
- @orange = '#EFAA43'
- @white = 'white'
- @colors = [@yellow, @blue, @green, @red, @purple, @orange, @white]
-
- self.theme = {
- :colors => @colors,
- :marker_color => 'white',
- :font_color => 'white',
- :background_colors => ['black', '#4a465a']
- }
+ self.theme = Themes::KEYNOTE
end
- # A color scheme plucked from the colors on the popular usability blog.
def theme_37signals
- # Colors
- @green = '#339933'
- @purple = '#cc99cc'
- @blue = '#336699'
- @yellow = '#FFF804'
- @red = '#ff0000'
- @orange = '#cf5910'
- @black = 'black'
- @colors = [@yellow, @blue, @green, @red, @purple, @orange, @black]
-
- self.theme = {
- :colors => @colors,
- :marker_color => 'black',
- :font_color => 'black',
- :background_colors => ['#d1edf5', 'white']
- }
+ self.theme = Themes::THIRTYSEVEN_SIGNALS
end
- # A color scheme from the colors used on the 2005 Rails keynote
- # presentation at RubyConf.
def theme_rails_keynote
- # Colors
- @green = '#00ff00'
- @grey = '#333333'
- @orange = '#ff5d00'
- @red = '#f61100'
- @white = 'white'
- @light_grey = '#999999'
- @black = 'black'
- @colors = [@green, @grey, @orange, @red, @white, @light_grey, @black]
-
- self.theme = {
- :colors => @colors,
- :marker_color => 'white',
- :font_color => 'white',
- :background_colors => ['#0083a3', '#0083a3']
- }
+ self.theme = Themes::RAILS_KEYNOTE
end
- # A color scheme similar to that used on the popular podcast site.
def theme_odeo
- # Colors
- @grey = '#202020'
- @white = 'white'
- @dark_pink = '#a21764'
- @green = '#8ab438'
- @light_grey = '#999999'
- @dark_blue = '#3a5b87'
- @black = 'black'
- @colors = [@grey, @white, @dark_blue, @dark_pink, @green, @light_grey, @black]
-
- self.theme = {
- :colors => @colors,
- :marker_color => 'white',
- :font_color => 'white',
- :background_colors => ['#ff47a4', '#ff1f81']
- }
+ self.theme = Themes::ODEO
end
- # A pastel theme
def theme_pastel
- # Colors
- @colors = [
- '#a9dada', # blue
- '#aedaa9', # green
- '#daaea9', # peach
- '#dadaa9', # yellow
- '#a9a9da', # dk purple
- '#daaeda', # purple
- '#dadada' # grey
- ]
-
- self.theme = {
- :colors => @colors,
- :marker_color => '#aea9a9', # Grey
- :font_color => 'black',
- :background_colors => 'white'
- }
+ self.theme = Themes::PASTEL
end
- # A greyscale theme
def theme_greyscale
- # Colors
- @colors = [
- '#282828', #
- '#383838', #
- '#686868', #
- '#989898', #
- '#c8c8c8', #
- '#e8e8e8', #
- ]
-
- self.theme = {
- :colors => @colors,
- :marker_color => '#aea9a9', # Grey
- :font_color => 'black',
- :background_colors => 'white'
- }
+ self.theme = Themes::GREYSCALE
end
# Parameters are an array where the first element is the name of the dataset
View
@@ -1,4 +1,5 @@
require File.dirname(__FILE__) + '/base'
+require 'gruff/themes'
# http://en.wikipedia.org/wiki/Bullet_graph
class Gruff::Bullet < Gruff::Base
@@ -16,7 +17,7 @@ def initialize(target_width="400x40")
initialize_ivars
reset_themes
- theme_greyscale
+ self.theme = Gruff::Themes::GREYSCALE
@title_font_size = 20
end
View
@@ -0,0 +1,102 @@
+module Gruff
+ module Themes
+
+ # A color scheme similar to the popular presentation software.
+ KEYNOTE = {
+ :colors => [
+ '#FDD84E', # yellow
+ '#6886B4', # blue
+ '#72AE6E', # green
+ '#D1695E', # red
+ '#8A6EAF', # purple
+ '#EFAA43', # orange
+ 'white'
+ ],
+ :marker_color => 'white',
+ :font_color => 'white',
+ :background_colors => ['black', '#4a465a']
+ }
+
+ # A color scheme plucked from the colors on the popular usability blog.
+ THIRTYSEVEN_SIGNALS = {
+ :colors => [
+ '#FFF804', # yellow
+ '#336699', # blue
+ '#339933', # green
+ '#ff0000', # red
+ '#cc99cc', # purple
+ '#cf5910', # orange
+ 'black'
+ ],
+ :marker_color => 'black',
+ :font_color => 'black',
+ :background_colors => ['#d1edf5', 'white']
+ }
+
+ # A color scheme from the colors used on the 2005 Rails keynote
+ # presentation at RubyConf.
+ RAILS_KEYNOTE = {
+ :colors => [
+ '#00ff00', # green
+ '#333333', # grey
+ '#ff5d00', # orange
+ '#f61100', # red
+ 'white',
+ '#999999', # light grey
+ 'black'
+ ],
+ :marker_color => 'white',
+ :font_color => 'white',
+ :background_colors => ['#0083a3', '#0083a3']
+ }
+
+ # A color scheme similar to that used on the popular podcast site.
+ ODEO = {
+ :colors => [
+ '#202020', # grey
+ 'white',
+ '#3a5b87', # dark blue
+ '#a21764', # dark pink
+ '#8ab438', # green
+ '#999999', # light grey
+ 'black'
+ ],
+ :marker_color => 'white',
+ :font_color => 'white',
+ :background_colors => ['#ff47a4', '#ff1f81']
+ }
+
+ # A pastel theme
+ PASTEL = {
+ :colors => [
+ '#a9dada', # blue
+ '#aedaa9', # green
+ '#daaea9', # peach
+ '#dadaa9', # yellow
+ '#a9a9da', # dk purple
+ '#daaeda', # purple
+ '#dadada' # grey
+ ],
+ :marker_color => '#aea9a9', # Grey
+ :font_color => 'black',
+ :background_colors => 'white'
+ }
+
+ # A greyscale theme
+ GREYSCALE = {
+ :colors => [
+ '#282828', #
+ '#383838', #
+ '#686868', #
+ '#989898', #
+ '#c8c8c8', #
+ '#e8e8e8', #
+ ],
+ :marker_color => '#aea9a9', # Grey
+ :font_color => 'black',
+ :background_colors => 'white'
+ }
+
+ end
+end
+
View
@@ -25,12 +25,12 @@ def test_bar_graph
g = setup_basic_graph
g.title = "Visual Multi-Line Bar Graph Test"
- g.theme_rails_keynote
+ g.theme = Gruff::Themes::RAILS_KEYNOTE
g.write("test/output/bar_rails_keynote.png")
g = setup_basic_graph
g.title = "Visual Multi-Line Bar Graph Test"
- g.theme_odeo
+ g.theme = Gruff::Themes::ODEO
g.write("test/output/bar_odeo.png")
end
View
@@ -535,7 +535,7 @@ def line_graph_with_themes(size=nil)
g.title = "Multi-Line Graph Test #{size}"
g.labels = @labels
g.baseline_value = 90
- g.theme_37signals
+ g.theme = Gruff::Themes::THIRTYSEVEN_SIGNALS
@datasets.each do |data|
g.data(data[0], data[1])
end
@@ -545,7 +545,7 @@ def line_graph_with_themes(size=nil)
g.title = "Multi-Line Graph Test #{size}"
g.labels = @labels
g.baseline_value = 90
- g.theme_rails_keynote
+ g.theme = Gruff::Themes::RAILS_KEYNOTE
@datasets.each do |data|
g.data(data[0], data[1])
end
@@ -555,7 +555,7 @@ def line_graph_with_themes(size=nil)
g.title = "Multi-Line Graph Test #{size}"
g.labels = @labels
g.baseline_value = 90
- g.theme_odeo
+ g.theme = Gruff::Themes::ODEO
@datasets.each do |data|
g.data(data[0], data[1])
end
View
@@ -30,7 +30,7 @@ def test_pie_graph
def test_pie_graph_greyscale
g = Gruff::Pie.new
g.title = "Greyscale Pie Graph Test"
- g.theme_greyscale
+ g.theme = Gruff::Themes::GREYSCALE
@datasets.each do |data|
g.data(data[0], data[1])
end
@@ -41,7 +41,7 @@ def test_pie_graph_greyscale
def test_pie_graph_pastel
g = Gruff::Pie.new
- g.theme_pastel
+ g.theme = Gruff::Themes::PASTEL
g.title = "Pastel Pie Graph Test"
@datasets.each do |data|
g.data(data[0], data[1])
View
@@ -106,7 +106,7 @@ def test_theme_37signals
g.data(data[0], data[1])
end
- g.theme_37signals
+ g.theme = Gruff::Themes::THIRTYSEVEN_SIGNALS
# Default theme
g.write("test/output/spider_37signals.png")

0 comments on commit 9c73a95

Please sign in to comment.