vendor/gems/ziya-2.1.7/lib/ziya/charts/base.rb
def add( *args )
      # TODO Validation categories = series, series = labels, etc...
      directive = args.shift
      case directive
        # BOZO !! Idea - could use a formatter object to specificy how you want to format this series
        when :axis_category_text
          categories = args.first.is_a?(Array) ? args.shift : []
          raise ArgumentError, "Must specify an array of categories" if categories.empty?
          # don't side effect the passed in categs
          categs = categories.clone
          categs.insert( 0, nil )
          @options[directive] = categs
        # BOZO !! Need to constrain this only scatter and bubble support this !!
        when :axis_category_label
          labels = args.first.is_a?(Array) ? args.shift : []
          raise ArgumentError, "Must specify an array of category labels" if labels.empty?
          @options[directive] = labels          
        when :composites
          composites = args.first.is_a?(Hash) ? args.shift: []
          raise ArgumentError, "Must specify a hash of id => url pairs for the composite chart(s)" if composites.empty?
          @options[directive] = composites
        when :axis_value_label
          values = args.first.is_a?(Array) ? args.shift : []
          raise ArgumentError, "Must specify an array of values" if values.empty?
          @options[directive] = values
        when :series
          series = {}
          legend = args.first.is_a?(String) ? args.shift : ""
          if args.first.is_a?( Array )
            points = args.shift || []
            raise ArgumentError, "Must specify an array of data points" if points.empty?
            # don't side effect the passed in series
            pts = points.clone
            pts.insert( 0, legend )
            series[:points] = pts
          else
            raise ArgumentError, "Must specify an array of data points"
          end
          url = args.shift          
          series[:url] = url if url
          @series_desc << series
        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
          # raise ArgumentError, "Must specify a value" if value.empty?
          @options[key] = value
        when :styles
          styles = args.first.is_a?(String) ? args.shift : ""
          raise ArgumentError, "Must specify a set of styles" if styles.to_s.empty?          
          @options[directive] = styles   
        when :chart_types
          types = args.first.is_a?(Array) ? args.shift : []
          raise ArgumentError, "Must specify a set of chart types" if types.to_s.empty?          
          @options[directive] = types                        
        when :theme
          theme = args.first.is_a?(String) ? args.shift : ""
          raise ArgumentError, "Must specify a theme name" if theme.to_s.empty?          
          @theme = "#{Ziya.themes_dir}/#{theme}"
        when :mode
          @render_mode = args.first.is_a?(Integer) ? args.shift : -1
          raise ArgumentError, "Must specify a valid generation mode" if @render_mode == -1          
        else raise ArgumentError, "Invalid directive must be one of " + 
                                 ":axis_category_text, :axis_value, :series, :user_data"
      end 
    end
# Add chart components to a given chart.  
# 
# The <tt>args</tt> must contain certain keys for the chart
# to be displayed correctly.
#
# === Directives
# * <tt>:axis_category_text</tt> -- Array of strings representing the x/y
#   axis ticks dependending on the chart type. This value is required.
#   In an x/y axis chart setup the category is the x axis unless the chart is
#   a bar chart.
# * <tt>:axis_category_label</tt> -- Array of strings representing the x axis
#   labels. This is supported only for Scatter and Bubble charts.
#   This value is optional. Specify nil for no label change.
# * <tt>:series</tt> -- Specifies the series name and chart data points as an array.
#   The series name will be used to display chart legends. You must have at least one 
#   of these tag defined. The data values may be specified as a straight up array of
#   strings or numbers but also as an array of hash representing the data points and 
#   their attributes such as note, label, tooltip, effect, etc..
# * <tt>:axis_value_label</tt> -- Array of strings representing the ticks on the x/y
#   axis depending on the chart type. This is symmetrical to the <tt>axis_category_label</tt> 
#   tag for the opposite chart axis. Specify nil for no label change.
# * <tt>:user_data</tt>:: -- Used to make user data available to the ERB templates in
#   the chart stylesheet yaml file. You must specify a key symbol and an ad-hoc value. 
#   The key will be used with the @options hash to access the user data.  
# * <tt>:composites</tt> -- Embeds multiple charts within the given chart via the 
#   draw image component. You must specify a hash of chart_id/url pairs.
# * <tt>:chart_types</tt> -- Specify the chart types per series. This option should                        
#   only be used with Mixed Charts !!    
# * <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
# Setup the category axis to with 3 ticks namely 2004, 2005, 2006
#   my_chart.add( :axis_category_text, ['2004', '2005', '2006'] )
#   
# Plain old series with integer data points
#   my_chart.add( :series, "series A", [ 10, 20, 30] )    
# Specifying custom series labels. You may specify the following attributes in the data point
# hash : :note, :label, :tooltip and effects such as :shadow, :glow, etc...
#   my_chart.add( :series, "series A", [ { :value => 10, :label => 'l1' }, { :value => 20, :label => 'l2' } ] )
Add chart components to a given chart.
The args must contain certain keys for the chart
to be displayed correctly.

Directives
:axis_category_text -- Array of strings representing the x/y
axis ticks dependending on the chart type. This value is required.
In an x/y axis chart setup the category is the x axis unless the chart is
a bar chart.
:axis_category_label -- Array of strings representing the x axis
labels. This is supported only for Scatter and Bubble charts.
This value is optional. Specify nil for no label change.
:series -- Specifies the series name and chart data points as an array.
The series name will be used to display chart legends. You must have at least one
of these tag defined. The data values may be specified as a straight up array of
strings or numbers but also as an array of hash representing the data points and
their attributes such as note, label, tooltip, effect, etc
:axis_value_label -- Array of strings representing the ticks on the x/y
axis depending on the chart type. This is symmetrical to the axis_category_label
tag for the opposite chart axis. Specify nil for no label change.
:user_data:: -- Used to make user data available to the ERB templates in
the chart stylesheet yaml file. You must specify a key symbol and an ad-hoc value.
The key will be used with the @options hash to access the user data.
:composites -- Embeds multiple charts within the given chart via the
draw image component. You must specify a hash of chart_id/url pairs.
:chart_types -- Specify the chart types per series. This option should
only be used with Mixed Charts
:theme -- Specify the use of a given named theme. The named theme must
reside in a directory named equaly under your application public/charts/themes.



Plain old series with integer data points
my_chart.add( :series, "series A", [ 10, 20, 30] )
Specifying custom series labels.
Add chart components to a given chart . The args must contain certain keys for the chart to be displayed correctly . Directives : axis_category_text -- Array of strings representing the x / y axis ticks dependending on the chart type . This value is required . In an x / y axis chart setup the category is the x axis unless the chart is a bar chart . : axis_category_label -- Array of strings representing the x axis labels . This is supported only for Scatter and Bubble charts . This value is optional . Specify nil for no label change . : series -- Specifies the series name and chart data points as an array . The series name will be used to display chart legends . You must have at least one of these tag defined . The data values may be specified as a straight up array of strings or numbers but also as an array of hash representing the data points and their attributes such as note label tooltip effect etc : axis_value_label -- Array of strings representing the ticks on the x / y axis depending on the chart type . This is symmetrical to the axis_category_label tag for the opposite chart axis . Specify nil for no label change . : user_data :: -- Used to make user data available to the ERB templates in the chart stylesheet yaml file . You must specify a key symbol and an ad - hoc value . The key will be used with the @options hash to access the user data . : composites -- Embeds multiple charts within the given chart via the draw image component . You must specify a hash of chart_id / url pairs . : chart_types -- Specify the chart types per series . This option should only be used with Mixed Charts : theme -- Specify the use of a given named theme . The named theme must reside in a directory named equaly under your application public / charts / themes . Plain old series with integer data points my_chart . add ( : series " series A " [ 10 20 30 ] ) Specifying custom series labels .
def add( *args )
      directive = args.shift
      case directive
        when :axis_category_text
          categories = args.first.is_a?(Array) ? args.shift : []
          raise ArgumentError, "Must specify an array of categories" if categories.empty?
          categs = categories.clone
          categs.insert( 0, nil )
          @options[directive] = categs
        when :axis_category_label
          labels = args.first.is_a?(Array) ? args.shift : []
          raise ArgumentError, "Must specify an array of category labels" if labels.empty?
          @options[directive] = labels          
        when :composites
          composites = args.first.is_a?(Hash) ? args.shift: []
          raise ArgumentError, "Must specify a hash of id => url pairs for the composite chart(s)" if composites.empty?
          @options[directive] = composites
        when :axis_value_label
          values = args.first.is_a?(Array) ? args.shift : []
          raise ArgumentError, "Must specify an array of values" if values.empty?
          @options[directive] = values
        when :series
          series = {}
          legend = args.first.is_a?(String) ? args.shift : ""
          if args.first.is_a?( Array )
            points = args.shift || []
            raise ArgumentError, "Must specify an array of data points" if points.empty?
            pts = points.clone
            pts.insert( 0, legend )
            series[:points] = pts
          else
            raise ArgumentError, "Must specify an array of data points"
          end
          url = args.shift          
          series[:url] = url if url
          @series_desc << series
        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 :styles
          styles = args.first.is_a?(String) ? args.shift : ""
          raise ArgumentError, "Must specify a set of styles" if styles.to_s.empty?          
          @options[directive] = styles   
        when :chart_types
          types = args.first.is_a?(Array) ? args.shift : []
          raise ArgumentError, "Must specify a set of chart types" if types.to_s.empty?          
          @options[directive] = types                        
        when :theme
          theme = args.first.is_a?(String) ? args.shift : ""
          raise ArgumentError, "Must specify a theme name" if theme.to_s.empty?          
          @theme = "#{Ziya.themes_dir}/#{theme}"
        when :mode
          @render_mode = args.first.is_a?(Integer) ? args.shift : -1
          raise ArgumentError, "Must specify a valid generation mode" if @render_mode == -1          
        else raise ArgumentError, "Invalid directive must be one of " + 
                                 ":axis_category_text, :axis_value, :series, :user_data"
      end 
    end
def add ( * args ) directive = args . shift case directive when :axis_category_text categories = args . first . is_a? ( Array ) ? args . shift : [ ] raise ArgumentError , "Must specify an array of categories" if categories . empty? categs = categories . clone categs . insert ( 0 , nil ) @options [ directive ] = categs when :axis_category_label labels = args . first . is_a? ( Array ) ? args . shift : [ ] raise ArgumentError , "Must specify an array of category labels" if labels . empty? @options [ directive ] = labels when :composites composites = args . first . is_a? ( Hash ) ? args . shift : [ ] raise ArgumentError , "Must specify a hash of id => url pairs for the composite chart(s)" if composites . empty? @options [ directive ] = composites when :axis_value_label values = args . first . is_a? ( Array ) ? args . shift : [ ] raise ArgumentError , "Must specify an array of values" if values . empty? @options [ directive ] = values when :series series = { } legend = args . first . is_a? ( String ) ? args . shift : "" if args . first . is_a? ( Array ) points = args . shift || [ ] raise ArgumentError , "Must specify an array of data points" if points . empty? pts = points . clone pts . insert ( 0 , legend ) series [ :points ] = pts else raise ArgumentError , "Must specify an array of data points" end url = args . shift series [ :url ] = url if url @series_desc << series 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 :styles styles = args . first . is_a? ( String ) ? args . shift : "" raise ArgumentError , "Must specify a set of styles" if styles . to_s . empty? @options [ directive ] = styles when :chart_types types = args . first . is_a? ( Array ) ? args . shift : [ ] raise ArgumentError , "Must specify a set of chart types" if types . to_s . empty? @options [ directive ] = types when :theme theme = args . first . is_a? ( String ) ? args . shift : "" raise ArgumentError , "Must specify a theme name" if theme . to_s . empty? @theme = "#{Ziya.themes_dir}/#{theme}" when :mode @render_mode = args . first . is_a? ( Integer ) ? args . shift : - 1 raise ArgumentError , "Must specify a valid generation mode" if @render_mode == - 1 else raise ArgumentError , "Invalid directive must be one of " + ":axis_category_text, :axis_value, :series, :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... # BOZO !! Idea - could use a formatter object to specificy how you want to format this series # don't side effect the passed in categs # BOZO !! Need to constrain this only scatter and bubble support this !! # don't side effect the passed in series # raise ArgumentError, "Must specify a value" if value.empty?
args