Class: SVG::Graph::BarBase

Inherits:
Graph
  • Object
show all
Defined in:
lib/SVG/Graph/BarBase.rb

Overview

Synopsis

A superclass for bar-style graphs. Do not attempt to instantiate directly; use one of the subclasses instead.

Author

Sean E. Russell <serATgermaneHYPHENsoftwareDOTcom>

Copyright 2004 Sean E. Russell This software is available under the Ruby license[LICENSE.txt]

Direct Known Subclasses

Bar, BarHorizontal

Constant Summary

Constants inherited from Graph

KEY_BOX_SIZE

Instance Attribute Summary

Instance Method Summary

Methods inherited from Graph

#add_data, #burn, #clear_data

Constructor Details

- (BarBase) initialize(config)

Ensures that :fields are provided in the configuration.



20
21
22
23
24
25
# File 'lib/SVG/Graph/BarBase.rb', line 20

def initialize config
  raise "fields was not supplied or is empty" unless config[:fields] &&
  config[:fields].kind_of?(Array) &&
  config[:fields].length > 0
  super
end

Instance Attribute Details

- (Object) bar_gap

Whether to have a gap between the bars or not, default

  is true, set to false if you don't want gaps.


36
37
38
# File 'lib/SVG/Graph/BarBase.rb', line 36

def bar_gap
  @bar_gap
end

- (Object) stack

How to stack data sets. :overlap overlaps bars with

  transparent colors, :top stacks bars on top of one another,
  :side stacks the bars side-by-side. Defaults to :overlap.


40
41
42
# File 'lib/SVG/Graph/BarBase.rb', line 40

def stack
  @stack
end

Instance Method Details

- (Object) set_defaults

In addition to the defaults set in Graph::initialize, sets

bar_gap
true
stack
:overlap


30
31
32
# File 'lib/SVG/Graph/BarBase.rb', line 30

def set_defaults
  init_with( :bar_gap => true, :stack => :overlap )
end