vendor/gems/ziya-2.1.7/lib/ziya/maps/base.rb
# Add chart components to a given chart.  
# 
# The <tt>args</tt> must contain certain keys for the chart
# to be displayed correctly.
#
# === Directives
# * <tt>:series</tt> -- Specifies the data points for the map. This must be a hash
#   of region, data pairs. Where the data is also a hash of attributes such as
#   :name, :data, :hover, :url and :target.
# * <tt>:range_colors</tt> -- Specifies the map of ranges of data values from the
#   series to a color on the map. The range may be an exact value such as 10 or an
#   actual range in the form of 1 - 10. The color must be an hexadecimal value of the
#   form 'ff00ff'.
# * <tt>:point_colors</tt> -- Specifies a map of valid color ranges to color the points
#   on the map. Valid key/value pairs are a number or range for the key and an 
#   associated color.
# * <tt>:arc_colors</tt> -- Specifies a map of valid color ranges to color the arcs
#   on the map. Valid key/value pairs are a number or range for the key and an 
#   associated color.    
# * <tt>:line_colors</tt> -- Specifies a map of valid color ranges to color the lines
#   on the map. Valid key/value pairs are a number or range for the key and an 
#   associated color.    
# * <tt>:lines</tt> -- Specifies a map of lines to plot on the map. These are key/value pairs.
#   The value represent the name of the line to be displayed. The value is a hash of attributes
#   as follows: :start, the geocode location of the point, :stop, the geocode location of the arc to end at 
#   :stroke, the thickness of the line and :data for the range value of the arc.
# * <tt>:arcs</tt> -- Specifies a map of arcs to plot on the map. These are key/value pairs.
#   The value represent the name of the arc to be displayed. The value is a hash of attributes
#   as follows: :start, the geocode location of the point, :stop, the geocode location of the arc to end at 
#   and :data for the range value of the arc.
# * <tt>:points</tt> -- Specifies a map of points to plot on the map. These are key/value pairs.
#   The value represent the name of the point to be displayed. The value is a hash of attributes
#   as follows: :loc for the geocode location of the point and :data for the range value of the point.
# * <tt>:theme</tt> -- Specify the use of a given named theme. The named theme must
#   reside in a directory named equaly under your application public/charts/themes.
#
# === Examples
# Colorize colorado and california on a US map
#   my_map.add( :series, { :CO => { :name => "Colorado", :data => 1 }, :CA => { :name => "California", :data => 2 } ) 
Add chart components to a given chart.
The args must contain certain keys for the chart
to be displayed correctly.

Directives
:series -- Specifies the data points for the map. This must be a hash
of region, data pairs.


Add chart components to a given chart . The args must contain certain keys for the chart to be displayed correctly . Directives : series -- Specifies the data points for the map . This must be a hash of region data pairs .
def add( *args )
      directive = args.shift
      case directive
        when :series
          if args.first.is_a?( Hash )
            points = args.shift || {}
            raise ArgumentError, "Must specify an hash of data points" if points.empty?
            @series = points
          else
            raise ArgumentError, "Must specify an hash of data points"
          end
        when :range_colors
          @range_colors = args.shift || {}
          raise ArgumentError, "You must specify a hash of data range/color pairs" if @range_colors.empty?          
        when :lines
          @lines = args.shift || {}
          raise ArgumentError, "You must specify a hash of lines attributes" if @lines.empty?
        when :line_colors
          @line_colors = args.shift || {}
          raise ArgumentError, "You must specify a hash of line range/color pairs" if @line_colors.empty?          
        when :arcs
          @arcs = args.shift || {}
          raise ArgumentError, "You must specify a hash of arcs attributes" if @arcs.empty?
        when :arc_colors
          @arc_colors = args.shift || {}
          raise ArgumentError, "You must specify a hash of arc range/color pairs" if @arc_colors.empty?          
        when :points
          @points = args.shift || {}
          raise ArgumentError, "You must specify a hash of points attributes" if @points.empty?
        when :point_colors
          @point_colors = args.shift || {}
          raise ArgumentError, "You must specify a hash of point range/color pairs" if @point_colors.empty?
        when :user_data
          key = args.first.is_a?(Symbol) ? args.shift : ""
          raise ArgumentError, "Must specify a key" if key.to_s.empty?
          value = args.shift
          @options[key] = value
        when :theme
          theme = args.first.is_a?(String) ? args.shift : ""
          raise ArgumentError, "Must specify a theme name" if theme.to_s.empty?          
          @theme = "#{Ziya.map_themes_dir}/#{theme}"
        else raise ArgumentError, "Invalid directive must be one of " + 
                                 ":series, :theme, :user_data"
      end 
    end
def add ( * args ) directive = args . shift case directive when :series if args . first . is_a? ( Hash ) points = args . shift || { } raise ArgumentError , "Must specify an hash of data points" if points . empty? @series = points else raise ArgumentError , "Must specify an hash of data points" end when :range_colors @range_colors = args . shift || { } raise ArgumentError , "You must specify a hash of data range/color pairs" if @range_colors . empty? when :lines @lines = args . shift || { } raise ArgumentError , "You must specify a hash of lines attributes" if @lines . empty? when :line_colors @line_colors = args . shift || { } raise ArgumentError , "You must specify a hash of line range/color pairs" if @line_colors . empty? when :arcs @arcs = args . shift || { } raise ArgumentError , "You must specify a hash of arcs attributes" if @arcs . empty? when :arc_colors @arc_colors = args . shift || { } raise ArgumentError , "You must specify a hash of arc range/color pairs" if @arc_colors . empty? when :points @points = args . shift || { } raise ArgumentError , "You must specify a hash of points attributes" if @points . empty? when :point_colors @point_colors = args . shift || { } raise ArgumentError , "You must specify a hash of point range/color pairs" if @point_colors . empty? when :user_data key = args . first . is_a? ( Symbol ) ? args . shift : "" raise ArgumentError , "Must specify a key" if key . to_s . empty? value = args . shift @options [ key ] = value when :theme theme = args . first . is_a? ( String ) ? args . shift : "" raise ArgumentError , "Must specify a theme name" if theme . to_s . empty? @theme = "#{Ziya.map_themes_dir}/#{theme}" else raise ArgumentError , "Invalid directive must be one of " + ":series, :theme, :user_data" end end
Add chart components to a given chart.
Add chart components to a given chart .
# TODO Validation categories = series, series = labels, etc... # raise ArgumentError, "Must specify a value" if value.empty?
args