Class: SVG::Graph::Plot

Class SVG::Graph::Plot |
In: | temp/Graph/Plot.rb
Parent: | Graph

# SVG::Graph::Plot

## 0.5.0

### For creating SVG plots of scalar data

# Synopsis

      require 'SVG/Graph/Plot'

      # Data sets are x,y pairs
      # Note that multiple data sets can differ in length, and that the
      # data in the datasets needn't be in order; they will be ordered
      # by the plot along the X-axis.
      projection = %w{
        6 11    0 5   18 7   1 11   13 9   1 2   19 0   3 13   7 9
      }
      actual = %w {
        0 18    8 15    9 4   18 14   10 2   11 6  14 12   15 6   4 17   2 12
      }

      graph = SVG::Graph::Plot.new({
              :height => 500,
              :width => 300,
        :key => true,
        :scale_x_integers => true,
        :scale_y_integerrs => true,
      })

      graph.add_data({
              :data => projection
        :title => 'Projected',
      })

      graph.add_data({
              :data => actual,
        :title => 'Actual',
      })

      print graph.burn()

# Description

Produces a graph of scalar data.

This object aims to allow you to easily create high quality SVG line graphs. You can either use the default style sheet or supply your own. Either way there are many options which can be configured to give you control over how the graph is generated - with or without a key, data elements at each point, title, subtitle etc.

# Notes

The default stylesheet handles upto 10 data sets, if you use more you must create your own stylesheet and add the additional settings for the extra data sets. You will know if you go over 10 data sets as they will have no style and be in black.

Unlike the other types of charts, data sets must contain x,y pairs:

      [ 1, 2 ]    # A data set with 1 point: (1,2)
      [ 1,2, 5,6] # A data set with 2 points: (1,2) and (5,6)

# See also

- SVG::Graph::Graph
- SVG::Graph::BarHorizontal
- SVG::Graph::Bar
- SVG::Graph::Line
- SVG::Graph::Pie
- SVG::Graph::TimeSeries

Methods

add_data set_defaults

Attributes

area_fill | [RW] | Fill the area under the line
min_x_value | [RW] | Set the minimum value of the X axis
min_y_value | [RW] | Set the minimum value of the Y axis
scale_x_divisions | [RW] |
scale_x_integers | [RW] | Make the X axis labels integers
scale_y_divisions | [RW] |
scale_y_integers | [RW] | Make the Y axis labels integers
show_data_points | [RW] | Show a small circle on the graph where the line goes from one point to the next.

Public Instance methods

set_defaults()

Defaults are those provided by the superclass Graph, and:

show_data_points
  true
area_fill
  false
stacked
  false

add_data(data)