Class SVG::Graph::Bar
In: temp/Graph/Bar.rb
Parent: BarBase

Create presentation quality SVG bar graphs easily

Synopsis

  require 'SVG/Graph/Bar'

  fields = %w(Jan Feb Mar);
  data_sales_02 = [12, 45, 21]

  graph = SVG::Graph::Bar.new(
    :height => 500,
    :width => 300,
    :fields => fields
  )

  graph.add_data(
    :data => data_sales_02,
    :title => 'Sales 2002'
  )

  print "Content-type: image/svg+xml\r\n\r\n"
  print graph.burn

Description

This object aims to allow you to easily create high quality SVG[www.w3c.org/tr/svg bar 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 12 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 12 data sets as they will have no style and be in black.

Examples

See also

Methods

Included Modules

REXML

Public Instance methods

See Graph::initialize and BarBase::set_defaults

Protected Instance methods

[Validate]