def add_series(params)
    raise "Must specify 'values' in add_series()" if params[:values].nil?

    # Parse the ranges to validate them and extract salient information.
    value_data    = parse_series_formula(params[:values])
    category_data = parse_series_formula(params[:categories])
    name_formula  = parse_series_formula(params[:name_formula])

    # Default category count to the same as the value count if not defined.
    category_data[1] = value_data[1] if category_data.size < 2

    # Add the parsed data to the user supplied data.
    params[:values]       = value_data
    params[:categories]   = category_data
    params[:name_formula] = name_formula

    # Encode the Series name.
    name, encoding = encode_utf16(params[:name], params[:name_encoding])

    params[:name]          = name
    params[:name_encoding] = encoding

    @series << params
  end
def add_series(params)
    raise "Must specify 'values' in add_series()" if params[:values].nil?

    # Parse the ranges to validate them and extract salient information.
    value_data    = parse_series_formula(params[:values])
    category_data = parse_series_formula(params[:categories])
    name_formula  = parse_series_formula(params[:name_formula])

    # Default category count to the same as the value count if not defined.
    category_data[1] = value_data[1] if category_data.size < 2

    # Add the parsed data to the user supplied data.
    params[:values]       = value_data
    params[:categories]   = category_data
    params[:name_formula] = name_formula

    # Encode the Series name.
    name, encoding = encode_utf16(params[:name], params[:name_encoding])

    params[:name]          = name
    params[:name_encoding] = encoding

    @series << params
  end
:call-seq:
   new(filename, name, index, encoding, activesheet, firstsheet, external_bin = nil)

 Default constructor for sub-classes.


 Add a series and it's properties to a chart.

 In an Excel chart a "series" is a collection of information such as values,
 x-axis labels and the name that define which data is plotted. These
 settings are displayed when you select the Chart -> Source Data... menu
 option.

 With a WriteExcel chart object the add_series() method is used to set the
 properties for a series:

     chart.add_series(
       :categories    => '=Sheet1!$A$2:$A$10',
       :values        => '=Sheet1!$B$2:$B$10',
       :name          => 'Series name',
       :name_formula  => '=Sheet1!$B$1'
     )

 The properties that can be set are:

     :values        (required)
     :categories    (optional for most chart types)
     :name          (optional)
     :name_formula  (optional)

     * :values

       This is the most important property of a series and must be set for
       every chart object. It links the chart with the worksheet data that
       it displays.

           chart.add_series(:values => '=Sheet1!$B$2:$B$10')

       Note the format that should be used for the formula. It is the same
       as is used in Excel. You must also add the worksheet that you are
       referring to before you link to it, via the workbook
       add_worksheet() method.

     * :categories

       This sets the chart category labels. The category is more or less
       the same as the X-axis. In most chart types the categories property
       is optional and the chart will just assume a sequential series
       from 1 .. n.

           chart.add_series(
             :categories    => '=Sheet1!$A$2:$A$10',
             :values        => '=Sheet1!$B$2:$B$10'
           )

     * :name

       Set the name for the series. The name is displayed in the chart
       legend and in the formula bar. The name property is optional and
       if it isn't supplied will default to Series 1 .. n.

           chart.add_series(
             ...
             :name          => 'Series name'
           )

     * :name_formula

       Optional, can be used to link the name to a worksheet cell.
       See "Chart names and links".

           chart.add_series(
             ...
             :name          => 'Series name',
             :name_formula  => '=Sheet1!$B$1'
           )

 You can add more than one series to a chart. The series numbering and
 order in the final chart is the same as the order in which that are added.

     # Add the first series.
     chart.add_series(
       :categories => '=Sheet1!$A$2:$A$7',
       :values     => '=Sheet1!$B$2:$B$7',
       :name       => 'Test data series 1'
     )

     # Add another series. Category is the same but values are different.
     chart.add_series(
       :categories => '=Sheet1!$A$2:$A$7',
       :values     => '=Sheet1!$C$2:$C$7',
       :name       => 'Test data series 2'
     )