Skip to content

Commit

Permalink
* Merge branch 'themes'
Browse files Browse the repository at this point in the history
  • Loading branch information
donv committed Nov 9, 2012
2 parents 8c35469 + 46f4e71 commit 9c73a95
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 114 deletions.
1 change: 1 addition & 0 deletions lib/gruff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Extra full path added to fix loading errors on some installations.

%w(
themes
base
area
bar
Expand Down
112 changes: 7 additions & 105 deletions lib/gruff/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/gruff/bullet.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require File.dirname(__FILE__) + '/base'
require 'gruff/themes'

# http://en.wikipedia.org/wiki/Bullet_graph
class Gruff::Bullet < Gruff::Base
Expand All @@ -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

Expand Down
102 changes: 102 additions & 0 deletions lib/gruff/themes.rb
Original file line number Diff line number Diff line change
@@ -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

4 changes: 2 additions & 2 deletions test/test_bar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions test/test_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/test_pie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion test/test_spider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 9c73a95

Please sign in to comment.