Class | Gruff::Scatter |
In: |
lib/gruff/scatter.rb
|
Parent: | Gruff::Base |
Here‘s how to set up an XY Scatter Chart
g = Gruff::Scatter.new(800) g.data(:apples, [1,2,3,4], [4,3,2,1]) g.data(‘oranges’, [5,7,8], [4,1,7]) g.write(‘test/output/scatter.png’)
marker_x_count | [RW] | The number of vertical lines shown for reference |
maximum_x_value | [RW] | Maximum X Value. The value will get overwritten by the max in the datasets. |
minimum_x_value | [RW] | Minimum X Value. The value will get overwritten by the min in the datasets. |
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().
name: | String or Symbol containing the name of the dataset. |
x_data_points: | An Array of of x-axis data points. |
y_data_points: | An Array of of y-axis data points. |
color: | The hex string for the color of the dataset. Defaults to nil. |
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 |
x_data_points is empty: | This error is raised when the array for the x-axis points are empty |
y_data_points is empty: | This error is raised when the array for the y-axis points are empty |
x_data_points.length != y_data_points.length: | Error means that the x and y axis point arrays do not match in length |
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’)