class GoogleVisualr::ColorFormat

Attributes

gradient_ranges[RW]
ranges[RW]

Public Class Methods

new() click to toggle source
# File lib/google_visualr/formatters.rb, line 47
def initialize
  @ranges           = Array.new
  @gradient_ranges  = Array.new
end

Public Instance Methods

add_gradient_range(from, to, color, fromBgColor, toBgColor) click to toggle source
# File lib/google_visualr/formatters.rb, line 56
def add_gradient_range(from, to, color, fromBgColor, toBgColor)
  @gradient_ranges <<  { :from => from, :to => to, :color => color, :fromBgColor => fromBgColor, :toBgColor => toBgColor }
end
add_range(from, to, color, bgcolor) click to toggle source
# File lib/google_visualr/formatters.rb, line 52
def add_range(from, to, color, bgcolor)
  @ranges << { :from => from, :to => to, :color => color, :bgcolor => bgcolor }
end
to_js() click to toggle source
Calls superclass method GoogleVisualr::Formatter#to_js
# File lib/google_visualr/formatters.rb, line 60
def to_js
  super do |js|
    @ranges.each do |r|
      js << "\nformatter.addRange(#{typecast(r[:from])}, #{typecast(r[:to])}, #{typecast(r[:color])}, #{typecast(r[:bgcolor])});"
    end
    @gradient_ranges.each do |r|
      js << "\nformatter.addGradientRange(#{typecast(r[:from])}, #{typecast(r[:to])}, #{typecast(r[:color])}, #{typecast(r[:fromBgColor])}, #{typecast(r[:toBgColor])});"
    end
  end
end