lib/gruff/scatter.rb
# The first parameter is the name of the dataset.  The next two are the
# x and y axis data points contain in their own array in that respective
# order.  The final parameter is the color.
#
# Can be called multiple times with different datasets for a multi-valued
# graph.
#
# If the color argument is nil, the next color from the default theme will
# be used.
#
# @note If you want to use a preset theme, you must set it before calling {#data}.
#
# @param name [String, Symbol] containing the name of the dataset.
# @param x_data_points [Array] An Array of of x-axis data points.
# @param y_data_points [Array] An Array of of y-axis data points.
# @param color [String] The hex string for the color of the dataset. Defaults to nil.
#
#
# @raise [ArgumentError] Data points contain nil values.
#   This error will get raised if either the x or y axis data points array
#   contains a +nil+ value.  The graph will not make an assumption
#   as how to graph +nil+.
# @raise [ArgumentError] +x_data_points+ is empty.
#   This error is raised when the array for the x-axis points are empty
# @raise [ArgumentError] +y_data_points+ is empty.
#   This error is raised when the array for the y-axis points are empty.
# @raise [ArgumentError] +x_data_points.length != y_data_points.length+.
#   Error means that the x and y axis point arrays do not match in length.
#
# @example
#   g = Gruff::Scatter.new
#   g.data(:apples, [1,2,3], [3,2,1])
#   g.data('oranges', [1,1,1], [2,3,4])
#   g.data('bitter_melon', [3,5,6], [6,7,8], '#000000')
#
The first parameter is the name of the dataset.  The next two are the
x and y axis data points contain in their own array in that respective
order.  The final parameter is the color.

Can be called multiple times with different datasets for a multi-valued
graph.

If the color argument is nil, the next color from the default theme will
be used.
The first parameter is the name of the dataset . The next two are the x and y axis data points contain in their own array in that respective order . The final parameter is the color . Can be called multiple times with different datasets for a multi - valued graph . If the color argument is nil the next color from the default theme will be used .
def data(name, x_data_points = [], y_data_points = [], color = nil)
    x_data_points = Array(x_data_points)
    y_data_points = Array(y_data_points)
    raise ArgumentError, 'Data Points contain nil Value!' if x_data_points.include?(nil) || y_data_points.include?(nil)
    raise ArgumentError, 'x_data_points is empty!' if x_data_points.empty?
    raise ArgumentError, 'y_data_points is empty!' if y_data_points.empty?
    raise ArgumentError, 'x_data_points.length != y_data_points.length!' if x_data_points.length != y_data_points.length
    store.add(name, y_data_points, color, x_data_points)
  end
def data ( name , x_data_points = [ ] , y_data_points = [ ] , color = nil ) x_data_points = Array ( x_data_points ) y_data_points = Array ( y_data_points ) raise ArgumentError , 'Data Points contain nil Value!' if x_data_points . include? ( nil ) || y_data_points . include? ( nil ) raise ArgumentError , 'x_data_points is empty!' if x_data_points . empty? raise ArgumentError , 'y_data_points is empty!' if y_data_points . empty? raise ArgumentError , 'x_data_points.length != y_data_points.length!' if x_data_points . length != y_data_points . length store . add ( name , y_data_points , color , x_data_points ) end
The first parameter is the name of the dataset.
The first parameter is the name of the dataset .
# make sure it's an array # Call the existing data routine for the x/y axis data
[ArgumentError] Data points contain nil values. This error will get raised if either the x or y axis data points array contains a +nil+ value. The graph will not make an assumption as how to graph +nil+.
[ ArgumentError ] Data points contain nil values . This error will get raised if either the x or y axis data points array contains a + nil + value . The graph will not make an assumption as how to graph + nil + .
[ArgumentError] +x_data_points+ is empty. This error is raised when the array for the x-axis points are empty
[ ArgumentError ] + x_data_points + is empty . This error is raised when the array for the x - axis points are empty
[ArgumentError] +y_data_points+ is empty. This error is raised when the array for the y-axis points are empty.
[ ArgumentError ] + y_data_points + is empty . This error is raised when the array for the y - axis points are empty .
[ArgumentError] +x_data_points.length != y_data_points.length+. Error means that the x and y axis point arrays do not match in length.
[ ArgumentError ] + x_data_points . length ! = y_data_points . length + . Error means that the x and y axis point arrays do not match in length .
name
containing the name of the dataset.
containing the name of the dataset .
x_data_points
An Array of of x-axis data points.
An Array of of x - axis data points .
y_data_points
An Array of of y-axis data points.
An Array of of y - axis data points .
color
The hex string for the color of the dataset. Defaults to nil.
The hex string for the color of the dataset . Defaults to nil .
note
If you want to use a preset theme, you must set it before calling {#data}.
If you want to use a preset theme you must set it before calling { #data } .
example
None