class Prawn::Graph::Theme
Constants
- Default
Attributes
theme[R]
Public Class Methods
default()
click to toggle source
The default theme is special, only create one of them.
# File lib/prawn/graph/theme.rb, line 9 def self.default @@_default_theme ||= Prawn::Graph::Theme.new(Prawn::Graph::Theme::Default) end
new(arg)
click to toggle source
# File lib/prawn/graph/theme.rb, line 13 def initialize(arg) @series_map = {} @current_series_color = 0 @theme = OpenStruct.new(Prawn::Graph::Theme::Default.merge(arg)) end
Public Instance Methods
==(other)
click to toggle source
# File lib/prawn/graph/theme.rb, line 23 def ==(other) theme == other.theme end
color_for(series)
click to toggle source
# File lib/prawn/graph/theme.rb, line 27 def color_for(series) @series_map[series.uuid] = cycle_color unless @series_map.has_key?(series.uuid) @series_map[series.uuid] end
font_sizes()
click to toggle source
# File lib/prawn/graph/theme.rb, line 32 def font_sizes @font_sizes ||= OpenStruct.new({default: 8, main_title: 10, axis_labels: 5, series_key: 8 }) end
method_missing(method_name, *arguments)
click to toggle source
# File lib/prawn/graph/theme.rb, line 36 def method_missing(method_name, *arguments) if arguments.any? @theme.send(method_name, arguments) else @theme.send(method_name) end end
number_of_colors()
click to toggle source
# File lib/prawn/graph/theme.rb, line 19 def number_of_colors theme.series.size end
Private Instance Methods
cycle_color()
click to toggle source
# File lib/prawn/graph/theme.rb, line 48 def cycle_color if @series_map.empty? @current_series_color = 0 else next_color_index = @current_series_color + 1 next_color_index = 0 if next_color_index == @theme.series.size @current_series_color = next_color_index end @theme.series[@current_series_color] end