Method: Gruff::Scatter#data
- Defined in:
- lib/gruff/scatter.rb
#data(name, x_data_points = [], y_data_points = [], color = nil) ⇒ Object Also known as: dataxy
Note:
If you want to use a preset theme, you must set it before calling #data.
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.
122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/gruff/scatter.rb', line 122 def data(name, x_data_points = [], y_data_points = [], color = nil) # make sure it's an array 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 # Call the existing data routine for the x/y axis data store.add(name, y_data_points, color, x_data_points) end |