Class SVG::Graph::BarBase
In: lib/SVG/Graph/BarBase.rb
Parent: SVG::Graph::Graph

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

Methods

Attributes

bar_gap  [RW]  Whether to have a gap between the bars or not, default is true, set to false if you don‘t want gaps.
stack  [RW]  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.

Public Class methods

Ensures that :fields are provided in the configuration.

[Source]

    # File lib/SVG/Graph/BarBase.rb, line 20
20:         def initialize config
21:             raise "fields was not supplied or is empty" unless config[:fields] &&
22:             config[:fields].kind_of?(Array) &&
23:             config[:fields].length > 0
24:             super
25:         end

Public Instance methods

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

bar_gap
true
stack
:overlap

[Source]

    # File lib/SVG/Graph/BarBase.rb, line 30
30:         def set_defaults
31:             init_with( :bar_gap => true, :stack => :overlap )
32:         end

Protected Instance methods

[Source]

    # File lib/SVG/Graph/BarBase.rb, line 58
58:       def get_css
59:         return "/* default fill styles for multiple datasets (probably only use a single dataset on this graph though) */\n.key1,.fill1{\n        fill: #ff0000;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 0.5px;   \n}\n.key2,.fill2{\n        fill: #0000ff;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key3,.fill3{\n        fill: #00ff00;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key4,.fill4{\n        fill: #ffcc00;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key5,.fill5{\n        fill: #00ccff;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key6,.fill6{\n        fill: #ff00ff;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key7,.fill7{\n        fill: #00ffff;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key8,.fill8{\n        fill: #ffff00;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key9,.fill9{\n        fill: #cc6666;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key10,.fill10{\n        fill: #663399;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key11,.fill11{\n        fill: #339900;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n.key12,.fill12{\n        fill: #9966FF;\n        fill-opacity: 0.5;\n        stroke: none;\n        stroke-width: 1px;     \n}\n"
60:       end

[Source]

    # File lib/SVG/Graph/BarBase.rb, line 43
43:         def max_value
44:         @data.collect{|x| x[:data].max}.max
45:         end

[Source]

    # File lib/SVG/Graph/BarBase.rb, line 47
47:       def min_value
48:         min = 0
49:         if min_scale_value.nil? 
50:           min = @data.collect{|x| x[:data].min}.min
51:           min = min > 0 ? 0 : min
52:         else
53:           min = min_scale_value
54:         end
55:         return min
56:       end

[Validate]