class Chart::Theme

Attributes

background[RW]
bar_colors[RW]
chart_background[RW]
colors[RW]

Public Class Methods

add_theme_file(file) click to toggle source

Allows you to specify paths for custom theme files in YAML format

# File lib/gchart/theme.rb, line 23
def self.add_theme_file(file)
  @@theme_files << file
end
load(theme_name) click to toggle source
# File lib/gchart/theme.rb, line 14
def self.load(theme_name)
  theme = new(theme_name)
end
new(theme_name) click to toggle source
# File lib/gchart/theme.rb, line 27
def initialize(theme_name)
  themes = {}
  @@theme_files.each {|f| themes.update YAML::load(File.open(f))}
  theme = themes[theme_name]
  if theme
    self.colors = theme[:colors]
    self.bar_colors = theme[:bar_colors]
    self.background = theme[:background]
    self.chart_background = theme[:chart_background]
    self
  else
    raise(ThemeNotFound, "Could not locate the #{theme_name} theme ...")
  end
end
theme_files() click to toggle source
# File lib/gchart/theme.rb, line 18
def self.theme_files
  @@theme_files
end

Public Instance Methods

to_options() click to toggle source
# File lib/gchart/theme.rb, line 42
def to_options
  {:background => background, :chart_background => chart_background, :bar_colors => bar_colors.join(',')}
end