Class: GoogleChart::MapChart

Inherits:
Base
  • Object
show all
Includes:
Color, DataArray, Fills
Defined in:
lib/google_chart/map_chart.rb

Constant Summary

GEOGRAPHICAL_AREAS =
[ :africa, :asia, :europe, :middle_east, :south_america, :usa, :world ]
ISO_3166_1_ALPHA_2 =
[ :AF, :AX, :AL, :DZ, :AS, :AD, :AO, :AI, :AQ, :AG, :AR, :AM, :AW, :AU, :AT, :AZ, :BS, :BH, :BD, :BB, :BY, :BE, :BZ, :BJ, :BM, :BT, :BO, :BA, :BW, :BV, :BR, :IO, :BN, :BG, :BF, :BI, :KH, :CM, :CA, :CV, :KY, :CF, :TD, :CL, :CN, :CX, :CC, :CO, :KM, :CG, :CD, :CK, :CR, :CI, :HR, :CU, :CY, :CZ, :DK, :DJ, :DM, :DO, :EC, :EG, :SV, :GQ, :ER, :EE, :ET, :FK, :FO, :FJ, :FI, :FR, :GF, :PF, :TF, :GA, :GM, :GE, :DE, :GH, :GI, :GR, :GL, :GD, :GP, :GU, :GT, :GG, :GN, :GW, :GY, :HT, :HM, :VA, :HN, :HK, :HU, :IS, :IN, :ID, :IR, :IQ, :IE, :IM, :IL, :IT, :JM, :JP, :JE, :JO, :KZ, :KE, :KI, :KP, :KR, :KW, :KG, :LA, :LV, :LB, :LS, :LR, :LY, :LI, :LT, :LU, :MO, :MK, :MG, :MW, :MY, :MV, :ML, :MT, :MH, :MQ, :MR, :MU, :YT, :MX, :FM, :MD, :MC, :MN, :ME, :MS, :MA, :MZ, :MM, :NA, :NR, :NP, :NL, :AN, :NC, :NZ, :NI, :NE, :NG, :NU, :NF, :MP, :NO, :OM, :PK, :PW, :PS, :PA, :PG, :PY, :PE, :PH, :PN, :PL, :PT, :PR, :QA, :RE, :RO, :RU, :RW, :BL, :SH, :KN, :LC, :MF, :PM, :VC, :WS, :SM, :ST, :SA, :SN, :RS, :SC, :SL, :SG, :SK, :SI, :SB, :SO, :ZA, :GS, :ES, :LK, :SD, :SR, :SJ, :SZ, :SE, :CH, :SY, :TW, :TJ, :TZ, :TH, :TL, :TG, :TK, :TO, :TT, :TN, :TR, :TM, :TC, :TV, :UG, :UA, :AE, :GB, :US, :UM, :UY, :UZ, :VU, :VE, :VN, :VG, :VI, :WF, :EH, :YE, :ZM, :ZW ]
STATE_ABBREVIATIONS =
[ :AL, :AK, :AZ, :AR, :CA, :CO, :CT, :DE, :DC, :FL, :GA, :HI, :ID, :IL, :IN, :IA, :KS, :KY, :LA, :ME, :MD, :MA, :MI, :MN, :MS, :MO, :MT, :NE, :NV, :NH, :NJ, :NM, :NY, :NC, :ND, :OH, :OK, :OR, :PA, :RI, :SC, :SD, :TN, :TX, :UT, :VT, :VA, :WA, :WV, :WI, :WY ]

Constants included from Fills

Fills::FILL_KINDS, Fills::FILL_TYPES, Fills::FILL_TYPES_SOLID, Fills::FILL_TYPE_CODES

Instance Attribute Summary (collapse)

Attributes inherited from Base

#encoding, #height, #title, #title_color, #title_font_size, #width

Instance Method Summary (collapse)

Methods included from Fills

#fill

Methods included from DataArray

#encode_data, included

Methods inherited from Base

inherited, #query_params, #size, #size=, #to_url

Constructor Details

- (MapChart) initialize(options = {})



15
16
17
18
19
20
# File 'lib/google_chart/map_chart.rb', line 15

def initialize(options={})
  @chart_type = 't'
  @show_legend = false
  @default_color = 'FFFFFF'
  super(options)
end

Instance Attribute Details

- (Object) default_color

Returns the value of attribute default_color



11
12
13
# File 'lib/google_chart/map_chart.rb', line 11

def default_color
  @default_color
end

- (Object) geographical_area

Returns the value of attribute geographical_area



11
12
13
# File 'lib/google_chart/map_chart.rb', line 11

def geographical_area
  @geographical_area
end

- (Object) gradient

Returns the value of attribute gradient



11
12
13
# File 'lib/google_chart/map_chart.rb', line 11

def gradient
  @gradient
end

Instance Method Details

- (Object) add_map_parameters

Called to add map-specific parameters to the query_params hash.



24
25
26
27
28
29
30
# File 'lib/google_chart/map_chart.rb', line 24

def add_map_parameters
  @params[:chtm] = geographical_area.to_s
  @params[:chld] = @region_codes.join('') unless @region_codes.empty?
  unless @default_color.empty?
    @params[:chco] = @params[:chco].empty? ? @default_color : "#{@default_color},#{@params[:chco]}"
  end
end

- (Object) data(code, data)

ACCESSORS.

Raises:

  • (ArgumentError)


36
37
38
39
40
# File 'lib/google_chart/map_chart.rb', line 36

def data(code, data)
  raise ArgumentError.new("data should be an integer value") unless data.is_a?(Numeric)
  @data << data
  region_code(code)
end